package com.fyx.service.impl;


import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fyx.config.*;
import com.fyx.entity.*;
import com.fyx.mapper.*;
import com.fyx.service.IGameDataService;
import com.fyx.until.DateUtil;
import com.fyx.until.HttpUtil;
import com.fyx.utils.RedisUtils;
import com.fyx.utils.SecurityUtils;
import com.mongodb.MongoClientURI;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.SimpleMongoDbFactory;
import org.springframework.data.mongodb.core.aggregation.Aggregation;
import org.springframework.data.mongodb.core.aggregation.AggregationResults;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.data.mongodb.core.aggregation.SkipOperation;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

import static org.springframework.data.mongodb.core.aggregation.Aggregation.match;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.sortByCount;

@Slf4j
@Service
public class GameDataServiceImpl extends ServiceImpl<SysDictDetailMapper, SysDictDetail> implements IGameDataService  {
    @Resource(name = PrimaryMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate mongoTemplate;

    @Resource(name = SecondaryMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate secondaryMongoTemplate;

    @Resource(name = FourthMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate fourthMongoTemplate;

    @Resource(name = FiveMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate fiveMongoTemplate;

    @Resource(name = SixthMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate sixthMongoTemplate;

    @Resource(name = EighthMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate eighthMongoTemplate;

    @Resource(name = NinethMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate ninethMongoTemplate;

    @Resource(name = TenthMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate tenthMongoTemplate;

    @Resource(name = EleventhMongoConfig.MONGO_TEMPLATE)
    private MongoTemplate eleventhMongoTemplate;

    @Autowired
    private SysDictDetailMapper sysDictDetailMapper;

    @Autowired
    private SysUserMapper sysUserMapper;

    @Override
    public Map getOnlineLists(ActiveDataEntity activeDataEntity, Pageable pageable) {
        List<OnlineUserEntity> list= new ArrayList<OnlineUserEntity>();
        List<OnlineUserEntity> list1= new ArrayList<OnlineUserEntity>();
        OnlineUserEntity onlineUserEntity = new OnlineUserEntity();
            JSONObject jsonObject = new JSONObject();
            JSONObject map = new JSONObject();
            map.put("cmd","get_channels_room_info");
            map.put("args",jsonObject);
            String result = null;
            try {
                result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (StringUtils.isBlank(result)){
                log.info("获取在线人数请求失败");
            }
            JSONObject resultJsonObject = JSONObject.parseObject(result);
            Integer j=0,g=0;
        int[][] player_num =new int[5][5];
        int playerNum =0;
            for (Object tkey :resultJsonObject.keySet() ){
                JSONObject resultJson=JSONObject.parseObject(resultJsonObject.getString(tkey.toString()));
                for (Object key :resultJson.keySet()) {
                    JSONObject roomsInfo=JSONObject.parseObject(resultJson.getString(key.toString()));
                    if(key=="online_count"){
                        for(Object counts:roomsInfo.keySet()){
                            if(counts.toString().indexOf(activeDataEntity.getNum())>-1&&Integer.parseInt(roomsInfo.getString(counts.toString()))>0) {
                                j += Integer.parseInt(roomsInfo.getString(counts.toString()));
                            }
                        }
                    }
                    else if(key=="room_info"){
                        for(Object counts:roomsInfo.keySet()) {
                            if(counts.toString().indexOf(activeDataEntity.getNum())>-1) {
                                JSONArray  a= roomsInfo.getJSONArray(counts.toString());
                                for(int b=0;b<5;b++){
                                    if(b<a.size()&&a.get(b)!=null) {
                                        JSONArray  c= a.getJSONArray(b) ;
                                        if(c.size()>0) {
                                            for (int d = 0; d < c.size(); d++) {
                                                if(c.get(d)!=null){
                                                    player_num[b][d]=Integer.parseInt(c.get(d).toString());
                                                    g += Integer.parseInt(c.get(d).toString());
                                                }
                                            }
                                        }else {   }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        for(int k=0;k<5;k++){
            onlineUserEntity.setPlay_num1(player_num[k][0]);
            onlineUserEntity.setPlay_num2(player_num[k][1]);
            onlineUserEntity.setPlay_num3(player_num[k][2]);
            onlineUserEntity.setPlay_num4(player_num[k][3]);
            onlineUserEntity.setPlay_num5(player_num[k][4]);
            list.add(onlineUserEntity);
        }

        Map map1 = new HashMap();
        OnlineUserEntity onlineUserEntity1 =new OnlineUserEntity();
        onlineUserEntity1.setOnline_num(j.toString());
        onlineUserEntity1.setPlay_num(g.toString());
        map1.put("countData",onlineUserEntity1);
        map1.put("content",list);

        return map1;
    }



    @Override
    public Map getOnlineList(ActiveDataEntity activeDataEntity, Pageable pageable) {
//        MongoClientURI mongoClientURI = new MongoClientURI("mongodb://root:Lianyun%40king_1022@dds-m5e5794d8138a4442218-pub.mongodb.rds.aliyuncs.com:3717/h5mj_game?replicaSet=mgset-37774823&maxIdleTimeMS=3000&authSource=admin&safe=true&authMechanism=SCRAM-SHA-1&maxPoolSize=500&minPoolSize=10");
//        SimpleMongoDbFactory mongoDbFactory = new SimpleMongoDbFactory(mongoClientURI);
//        MongoTemplate mongoTemplate = new MongoTemplate(mongoDbFactory);
        List<OnlineUserEntity> list= new ArrayList<OnlineUserEntity>();
        List<OnlineUserEntity> list1= new ArrayList<OnlineUserEntity>();
        System.out.println(activeDataEntity);
        OnlineUserEntity onlineUserEntity1 = new OnlineUserEntity();
        int plays=0;
        if(activeDataEntity.getNum()==null || activeDataEntity.getNum().equals("0")){
            JSONObject jsonObject = new JSONObject();
            JSONObject map = new JSONObject();
            map.put("cmd","get_room_info");
            map.put("args",jsonObject);
            String result = null;
            try {
                result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
                if(activeDataEntity.getChannel()!=null&&activeDataEntity.getChannel().equals("totalcl")){
                    result = HttpUtil.post(RequestConfig.baseRequestUrl2, map.toJSONString(),"utf-8");
                }else if(activeDataEntity.getChannel()!=null&&activeDataEntity.getChannel().equals("totalapp")){
                    result = HttpUtil.post(RequestConfig.baseRequestUrl1, map.toJSONString(),"utf-8");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (StringUtils.isBlank(result)){
                log.info("获取在线人数请求失败");
            }
                JSONObject resultJsonObject = JSONObject.parseObject(result);
                for (Object tkey :resultJsonObject.keySet() ){
                       JSONObject resultJson=JSONObject.parseObject(resultJsonObject.getString(tkey.toString()));
                        for (Object key :resultJson.keySet()) {
                        String mapKey = (String) key;
                        OnlineUserEntity onlineUserEntity = new OnlineUserEntity();
                        if(!mapKey.equals("online_num")){
                            Map onlineUserMap = (Map) resultJson.get(mapKey);
                            onlineUserEntity.setGame_num(mapKey);
                            if(mapKey.equals("6")) {
                                onlineUserEntity.setGame_des("不洗牌");
                            }else if(mapKey.equals("9")){
                                onlineUserEntity.setGame_des("克隆排位赛");
                            }
                                else {

                                onlineUserEntity.setGame_des((String) onlineUserMap.get("game_des"));
                            }
                            JSONArray detail  =(JSONArray) onlineUserMap.get("detail");
                            int[] room_num = new int[6];
                            int[] player_num =new int[6];
                            if(detail.size()>0){
                                for(int j=0;j<6;j++){
                                    try{
                                        JSONObject detailObject =detail.getJSONObject(j);
                                        room_num[j]=(int)detailObject.get("room_num");
                                        player_num[j]=(int)detailObject.get("player_num");
                                    }catch (Exception e){
                                        room_num[j]=0;
                                        player_num[j]=0;
                                    }
                                }
                                onlineUserEntity.setRoom_num1(onlineUserEntity.getRoom_num1()+room_num[0]);
                                onlineUserEntity.setRoom_num2(onlineUserEntity.getRoom_num2()+room_num[1]);
                                onlineUserEntity.setRoom_num3(onlineUserEntity.getRoom_num3()+room_num[2]);
                                onlineUserEntity.setRoom_num4(onlineUserEntity.getRoom_num4()+room_num[3]);
                                onlineUserEntity.setRoom_num5(onlineUserEntity.getRoom_num5()+room_num[4]);
                                onlineUserEntity.setRoom_num6(onlineUserEntity.getRoom_num6()+room_num[5]);

                                onlineUserEntity.setPlay_num1(onlineUserEntity.getPlay_num1()+player_num[0]);
                                onlineUserEntity.setPlay_num2(onlineUserEntity.getPlay_num2()+player_num[1]);
                                onlineUserEntity.setPlay_num3(onlineUserEntity.getPlay_num3()+player_num[2]);
                                onlineUserEntity.setPlay_num4(onlineUserEntity.getPlay_num4()+player_num[3]);
                                onlineUserEntity.setPlay_num5(onlineUserEntity.getPlay_num5()+player_num[4]);
                                onlineUserEntity.setPlay_num6(onlineUserEntity.getPlay_num6()+player_num[5]);
                            }
                        }else{
                            plays+=(int)resultJson.get(mapKey);
                        }
                        list.add(onlineUserEntity);
                     }
                }
        }
        for  ( int  i  =   0 ; i  <  list.size()  -   1 ; i ++ )  {
            for  ( int  j  =  list.size()  -   1 ; j  >  i; j -- )  {
                if  (list.get(j).getGame_num()!=null&&list.get(j).getGame_num().equals(list.get(i).getGame_num()))  {
                    list.get(i).setPlay_num1(list.get(j).getPlay_num1()+list.get(i).getPlay_num1());
                    list.get(i).setPlay_num2(list.get(j).getPlay_num2()+list.get(i).getPlay_num2());
                    list.get(i).setPlay_num3(list.get(j).getPlay_num3()+list.get(i).getPlay_num3());
                    list.get(i).setPlay_num4(list.get(j).getPlay_num4()+list.get(i).getPlay_num4());
                    list.get(i).setPlay_num5(list.get(j).getPlay_num5()+list.get(i).getPlay_num5());
                    list.get(i).setPlay_num6(list.get(j).getPlay_num6()+list.get(i).getPlay_num6());

                    list.get(i).setRoom_num1(list.get(j).getRoom_num1()+list.get(i).getRoom_num1());
                    list.get(i).setRoom_num2(list.get(j).getRoom_num2()+list.get(i).getRoom_num2());
                    list.get(i).setRoom_num3(list.get(j).getRoom_num3()+list.get(i).getRoom_num3());
                    list.get(i).setRoom_num4(list.get(j).getRoom_num4()+list.get(i).getRoom_num4());
                    list.get(i).setRoom_num5(list.get(j).getRoom_num5()+list.get(i).getRoom_num5());
                    list.get(i).setRoom_num6(list.get(j).getRoom_num6()+list.get(i).getRoom_num6());
                    list.remove(j);
                }else if(list.get(j).getGame_des()==null){
                    list.remove(j);
                }
            }
        }
        int room_num=0;
        int player_num=0;
        for( OnlineUserEntity onlineUserEntity2:list){
            int room_num1;
            if(onlineUserEntity2.getRoom_num1()==0){
                room_num1=0;
            }else{
                room_num1=onlineUserEntity2.getRoom_num1();
            }

            int room_num2;
            if(onlineUserEntity2.getRoom_num2()==0){
                room_num2=0;
            }else{
                room_num2=onlineUserEntity2.getRoom_num2();
            }

            int room_num3;
            if(onlineUserEntity2.getRoom_num3()==0){
                room_num3=0;
            }else{
                room_num3=onlineUserEntity2.getRoom_num3();
            }

            int room_num4;
            if(onlineUserEntity2.getRoom_num4()==0){
                room_num4=0;
            }else{
                room_num4=onlineUserEntity2.getRoom_num4();
            }

            int room_num5;
            if(onlineUserEntity2.getRoom_num5()==0){
                room_num5=0;
            }else{
                room_num5=onlineUserEntity2.getRoom_num5();
            }

            int room_num6;
            if(onlineUserEntity2.getRoom_num6()==0){
                room_num6=0;
            }else{
                room_num6=onlineUserEntity2.getRoom_num6();
            }
            room_num=room_num+room_num1+room_num2+room_num3+room_num4+room_num5+room_num6;

            int play_num1;
            if(onlineUserEntity2.getPlay_num1()==0){
                play_num1=0;
            }else{
                play_num1=onlineUserEntity2.getPlay_num1();
            }

            int play_num2;
            if(onlineUserEntity2.getPlay_num2()==0){
                play_num2=0;
            }else{
                play_num2=onlineUserEntity2.getPlay_num2();
            }

            int play_num3;
            if(onlineUserEntity2.getPlay_num3()==0){
                play_num3=0;
            }else{
                play_num3 =onlineUserEntity2.getPlay_num3();
            }

            int play_num4;
            if(onlineUserEntity2.getPlay_num4()==0){
                play_num4=0;
            }else{
                play_num4 =onlineUserEntity2.getPlay_num4();
            }

            int play_num5;
            if(onlineUserEntity2.getPlay_num5()==0){
                play_num5=0;
            }else{
                play_num5=onlineUserEntity2.getPlay_num5();
            }
            int play_num6;
            if(onlineUserEntity2.getPlay_num6()==0){
                play_num6=0;
            }else{
                play_num6=onlineUserEntity2.getPlay_num6();
            }
            player_num=player_num+play_num1+play_num2+play_num3+play_num4+play_num5+play_num6;
        }

        onlineUserEntity1.setRoom_num(room_num+"");
        onlineUserEntity1.setPlay_num(player_num+"");
        onlineUserEntity1.setOnline_num(plays+"");
        list1.add(onlineUserEntity1);

        Map map1 =new HashMap();
        List<OnlineUserEntity> list3= new ArrayList<OnlineUserEntity>();
        try {
            if(activeDataEntity.getChannel()!=null&&activeDataEntity.getChannel().equals("totalcl")){
                list3.add(list.stream().filter(d -> "3".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d->"8".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d->"9".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "12".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "13".equals(d.getGame_num())).findAny().get());
            }else if(activeDataEntity.getChannel()!=null&&activeDataEntity.getChannel().equals("total")){
                list3.add(list.stream().filter(d -> "5".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "2".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "1".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "3".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "4".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "6".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "7".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "10".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "11".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "13".equals(d.getGame_num())).findAny().get());
            }else{
                list3.add(list.stream().filter(d -> "5".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "2".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "1".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "3".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "4".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "6".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "7".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "10".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "11".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "13".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "3".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d->"8".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d->"9".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "12".equals(d.getGame_num())).findAny().get());
                list3.add(list.stream().filter(d -> "13".equals(d.getGame_num())).findAny().get());
            }
        }catch (Exception e){
            list3 = list;
        }

        map1.put("content",list3);
        map1.put("countData",list1);

        //今日数据
        String Qtime= DateUtil.timeStamp2Date(String.valueOf(new Date().getTime()/1000),"yyyy-MM-dd");
        Query query = new Query();
       Criteria criteria = new Criteria();
        if(activeDataEntity.getQTime()==null){
            criteria.andOperator(Criteria.where("time").gte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))).lte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))+86399));
        }else{
            criteria.andOperator(Criteria.where("time").gte(activeDataEntity.getQTime().get(0).getTime()/1000).lte(activeDataEntity.getQTime().get(1).getTime()/1000));
        }
        if(activeDataEntity.getChannel()==null){
            criteria.orOperator(Criteria.where("channel").exists(false),Criteria.where("channel").is("total"));
        }else {
            criteria.and("channel").is(activeDataEntity.getChannel());
        }
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.ASC,new String[]{"time"}));
        List<ActiveUserEntity> todayDataList = mongoTemplate.find(query, ActiveUserEntity.class);

        //去重
        for (int i = 0; i < todayDataList.size() - 1; i++) {
            for (int j = todayDataList.size() - 1; j > i; j--) {
                long time =todayDataList.get(j).getTime();
                long time1=todayDataList.get(i).getTime();
                String quantum = todayDataList.get(j).getQuantum();
                String quantum1 = todayDataList.get(i).getQuantum();
                if(time==time1&&quantum.equals(quantum1)){
                    todayDataList.remove(j);
                }
            }
        }

        int[] todayData = new int[todayDataList.size()];

        for(int x=0;x<todayDataList.size();x++){
            ActiveUserEntity activeUserEntity1=todayDataList.get(x);
            todayData[x]=activeUserEntity1.getNum();
        }

        //昨日数据
        query = new Query();
        criteria = new Criteria();
        if(activeDataEntity.getQTime()==null){
            criteria.andOperator(Criteria.where("time").gte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))-86400).lte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))+86399-24*3600));
        }else{
            criteria.andOperator(Criteria.where("time").gte(activeDataEntity.getQTime().get(0).getTime()/1000-24*3600).lte(activeDataEntity.getQTime().get(1).getTime()/1000-24*3600));
        }
        if(activeDataEntity.getChannel()==null){
            criteria.orOperator(Criteria.where("channel").exists(false),Criteria.where("channel").is("total"));
        }else {
            criteria.and("channel").is(activeDataEntity.getChannel());
        }
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.ASC,new String[]{"time"}));
        List<ActiveUserEntity> yestodayDataList=mongoTemplate.find(query, ActiveUserEntity.class);
        //去重
        for (int i = 0; i < yestodayDataList.size() - 1; i++) {
            for (int j = yestodayDataList.size() - 1; j > i; j--) {
                long time =yestodayDataList.get(j).getTime();
                long time1=yestodayDataList.get(i).getTime();
                String quantum = yestodayDataList.get(j).getQuantum();
                String quantum1 = yestodayDataList.get(i).getQuantum();
                if(time==time1&&quantum.equals(quantum1)){
                    yestodayDataList.remove(j);
                }
            }
        }

        int[] yestodayData = new int[yestodayDataList.size()];
        for(int x=0;x<yestodayDataList.size();x++){
            ActiveUserEntity activeUserEntity1=yestodayDataList.get(x);
            yestodayData[x]=activeUserEntity1.getNum();
        }

        //3日数据
        query = new Query();
        criteria = new Criteria();
        if(activeDataEntity.getQTime()==null){
            criteria.andOperator(Criteria.where("time").gte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))-86400*3).lte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))+86399-24*3600*3));
        }else{
            criteria.andOperator(Criteria.where("time").gte(activeDataEntity.getQTime().get(0).getTime()/1000-24*3600*3).lte(activeDataEntity.getQTime().get(1).getTime()/1000-24*3600*3));
        }
        if(activeDataEntity.getChannel()==null){
            criteria.orOperator(Criteria.where("channel").exists(false),Criteria.where("channel").is("total"));
        }else {
            criteria.and("channel").is(activeDataEntity.getChannel());
        }
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.ASC,new String[]{"time"}));
        List<ActiveUserEntity> threeDataList=mongoTemplate.find(query, ActiveUserEntity.class);
        //去重
        for (int i = 0; i < threeDataList.size() - 1; i++) {
            for (int j = threeDataList.size() - 1; j > i; j--) {
                long time =threeDataList.get(j).getTime();
                long time1=threeDataList.get(i).getTime();
                String quantum = threeDataList.get(j).getQuantum();
                String quantum1 = threeDataList.get(i).getQuantum();
                if(time==time1&&quantum.equals(quantum1)){
                    threeDataList.remove(j);
                }
            }
        }

        int[] threeData = new int[threeDataList.size()];
        for(int x=0;x<threeDataList.size();x++){
            ActiveUserEntity activeUserEntity1=threeDataList.get(x);
            threeData[x]=activeUserEntity1.getNum();
        }

        //7日数据
        query = new Query();
        criteria = new Criteria();
        if(activeDataEntity.getQTime()==null){
            criteria.andOperator(Criteria.where("time").gte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))-86400*7).lte(Integer.valueOf(DateUtil.date2TimeStamp(Qtime,"yyyy-MM-dd"))+86399-24*3600*7));
        }else{
            criteria.andOperator(Criteria.where("time").gte(activeDataEntity.getQTime().get(0).getTime()/1000-24*3600*7).lte(activeDataEntity.getQTime().get(1).getTime()/1000-24*3600*7));
        }
        if(activeDataEntity.getChannel()==null){
            criteria.orOperator(Criteria.where("channel").exists(false),Criteria.where("channel").is("total"));
        }else {
            criteria.and("channel").is(activeDataEntity.getChannel());
        }
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.ASC,new String[]{"time"}));
        List<ActiveUserEntity> sevenDataList=mongoTemplate.find(query, ActiveUserEntity.class);
        //去重
        for (int i = 0; i < sevenDataList.size() - 1; i++) {
            for (int j = sevenDataList.size() - 1; j > i; j--) {
                long time =sevenDataList.get(j).getTime();
                long time1=sevenDataList.get(i).getTime();
                String quantum = sevenDataList.get(j).getQuantum();
                String quantum1 = sevenDataList.get(i).getQuantum();
                if(time==time1&&quantum.equals(quantum1)){
                    sevenDataList.remove(j);
                }
            }
        }

        int[] sevenData = new int[sevenDataList.size()];
        for(int x=0;x<sevenDataList.size();x++){
            ActiveUserEntity activeUserEntity1=sevenDataList.get(x);
            sevenData[x]=activeUserEntity1.getNum();
        }

        List<ActiveUserEntity> xDataList = new ArrayList<>();

        int xDataSize=0;
        xDataSize=yestodayDataList.size();
        xDataList.addAll(yestodayDataList);
        String[] xData = new String[xDataSize];
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        for(int x=0;x<xDataList.size();x++){
            ActiveUserEntity activeUserEntity1=xDataList.get(x);
            String dateStr=null;
            if(activeDataEntity.getQTime()==null){
                Date date = new Date();
                dateStr = sdf.format(date);
            }else{
                long time =activeUserEntity1.getTime()+24*3600;
                Date date = new Date(time*1000);
                dateStr = sdf.format(date);
            }
            xData[x]=dateStr +" " +activeUserEntity1.getQuantum();
        }
        Map yDataMap = new HashMap();
        yDataMap.put("todayData",todayData);
        yDataMap.put("yestodayData",yestodayData);
        yDataMap.put("threeData",threeData);
        yDataMap.put("sevenData",sevenData);

        map1.put("chartData",yDataMap);
        map1.put("xData",xData);
        return map1;
    }

    @Override
    public Map GamesRoundInfo(GamesInfoEntity gamesInfoEntity, Pageable pageable){
        Query query = new Query();
        query.skip((pageable.getPageNumber())*pageable.getPageSize());
        query.limit(pageable.getPageSize());
        Criteria criteria=new Criteria();
        if(gamesInfoEntity.getQTime()!=null){
            criteria.and("unix_time").gte(gamesInfoEntity.getQTime().get(0).getTime()/1000).lte(gamesInfoEntity.getQTime().get(1).getTime()/1000);
        }
        if(StringUtils.isNotBlank(gamesInfoEntity.getUser_id())){
            criteria.and("user_id").is(gamesInfoEntity.getUser_id());
        }
        if(StringUtils.isNotBlank(gamesInfoEntity.getRoom_id())){
            criteria.and("room_id").is(gamesInfoEntity.getRoom_id());
        }
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"unix_time"}));
        List<GamesInfoEntity> list=secondaryMongoTemplate.find(query,GamesInfoEntity.class);
        Long total=secondaryMongoTemplate.count(query,GamesInfoEntity.class);
        Map map=new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        return map;
    }

    @Override
    public Map getOnlineUserList(OnlineUserInfoEntity onlineUserInfoEntity, Pageable pageable) {
        String ids="";
        List<OnlineUserInfoEntity> list = new ArrayList<>();
        if(onlineUserInfoEntity.getGameid()!=0 && onlineUserInfoEntity.getPlaceid()!=0){
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("gameid",onlineUserInfoEntity.getGameid());
            jsonObject.put("placeid",onlineUserInfoEntity.getPlaceid());
            JSONObject map = new JSONObject();
            map.put("cmd","get_room_players_info");
            map.put("args",jsonObject);
            String str = null;
            try {
                str=HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
            } catch (IOException e) {
                e.printStackTrace();
            }

            if(!str.equals("{}")){
                try{
                    Map<String, OnlineUserInfoEntity> params = JSONObject.parseObject(str, new TypeReference<Map<String, OnlineUserInfoEntity>>(){});
                    Iterator<Map.Entry<String, OnlineUserInfoEntity>> it = params.entrySet().iterator();
                    while (it.hasNext()) {
                        Map.Entry<String, OnlineUserInfoEntity> entry = it.next();
                        list.add(entry.getValue());
                        ids=entry.getValue().getId()+","+ids;
                    }
                }catch(Exception e){
                    System.out.println("获取玩家信息场次不存在！");
                }
            }
        }

        List<UserEntity> list1 = new ArrayList<>();
        if(onlineUserInfoEntity.getCountgold()!=0){
            Criteria criteria = new Criteria();
            criteria.and("bank").exists(true);
            criteria.and("id").in(ids.split(","));
            if(onlineUserInfoEntity.getGold()!=0){
                criteria.and("gold").gte(onlineUserInfoEntity.getGold());
            }
            criteria.and("countgold").gte(onlineUserInfoEntity.getCountgold());

            Aggregation aggregation = Aggregation.newAggregation(
                    Aggregation.project("id","userid","headimgurl","gold","bank.bankgold").andExpression("add('$gold','$bank.bankgold')").as("countgold"),
                    Aggregation.match(criteria),
                    Aggregation.sort(Sort.Direction.ASC,new String[]{"userid"}),
                    new SkipOperation(pageable.getPageNumber()*pageable.getPageSize()),
                    Aggregation.limit(pageable.getPageSize())
            );
            AggregationResults<UserEntity> ar = mongoTemplate.aggregate(aggregation, "user", UserEntity.class);
            list1 = ar.getMappedResults();
        }else{
            Query query=new Query();
            query.skip((pageable.getPageNumber())*pageable.getPageSize());
            query.limit(pageable.getPageSize());
            Criteria criteria = new Criteria();
            criteria.and("userid").in(ids.split(","));
            if(onlineUserInfoEntity.getGold()!=0){
                criteria.and("gold").gte(onlineUserInfoEntity.getGold());
            }
            query.addCriteria(criteria);
            query.with( Sort.by(Sort.Direction.DESC,new String[]{"userid"}));
            list1=mongoTemplate.find(query,UserEntity.class);
        }

        long total = mongoTemplate.count(new Query(new Criteria().and("userid").in(ids.split(","))), UserEntity.class);

        Map map2 =new HashMap();
        map2.put("content",list1);
        map2.put("totalElements",total);
        return map2;
    }

    @Override
    public User1Entity gameOneUser(User1Entity userEntity){
        Query query = new Query();
        User1Entity userEntity1=new User1Entity();
        if(userEntity.getFlag().equals("clmj")){
            userEntity1= fiveMongoTemplate.findOne(query.addCriteria(Criteria.where("userid").is(userEntity.getUserid())), User1Entity.class);
            userEntity1.setFlag("clmj");
        }else{

            userEntity1= mongoTemplate.findOne(query.addCriteria(Criteria.where("userid").is(userEntity.getUserid())), User1Entity.class);
            userEntity1.setFlag("hzmj");
        }
        return  userEntity1;
    }
    @Override
    public Map gameUser(UserEntity userEntity, Pageable pageable) {

      //  System.out.println("user is===================="+userEntity);
        Query query = new Query();
        query.skip((pageable.getPageNumber())*pageable.getPageSize());
        query.limit(pageable.getPageSize());
        Criteria criteria = new Criteria();
        if (userEntity.getUserid()!=null){
            criteria.and("userid").is(userEntity.getUserid());
        }

        if (userEntity.getNickname()!=null){
            String nickname =userEntity.getNickname();
            if(nickname.contains("+")){
                nickname=nickname.replace("+","\\+");
            }
            criteria.and("nickname").regex(nickname);
        }

        List<Criteria> criteriaList = new ArrayList<>();
        if(userEntity.getOpenid()!=null){
            criteriaList.add(Criteria.where("openid").is(userEntity.getOpenid()));
        }
        if(userEntity.getChannel()!=null){
            criteriaList.add(Criteria.where("channel").is(userEntity.getChannel()));
        }
        if (userEntity.getGold1()!=null ){
            criteriaList.add(Criteria.where("gold").gte(userEntity.getGold1()));
        }
        if (userEntity.getGold2()!=null ){
            criteriaList.add(Criteria.where("gold").lte(userEntity.getGold2()));
        }

        if (userEntity.getDiamond1()!=0 ){
            criteriaList.add(Criteria.where("diamond").gte(userEntity.getDiamond1()));
        }

        if (userEntity.getDiamond2()!=0 ){
            criteriaList.add(Criteria.where("diamond").lte(userEntity.getDiamond2()));
        }

        if (userEntity.getBankgold1()!=0 ){
            criteriaList.add(Criteria.where("bank.bankgold").gte(userEntity.getBankgold1()));
        }

        if (userEntity.getBankgold2()!=0 ){
            criteriaList.add(Criteria.where("bank.bankgold").lte(userEntity.getBankgold2()));
        }

        if (userEntity.getQregTime()!=null){
            criteriaList.add(Criteria.where("reg_time").gte(userEntity.getQregTime().get(0).getTime()/1000).lte(userEntity.getQregTime().get(1).getTime()/1000));
        }


        if(userEntity.getMarkNum()>0){
            criteriaList.add(Criteria.where("markNum").is(userEntity.getMarkNum()-1));
        }

        if(userEntity.getPhone_idfa()!=null){
            criteriaList.add(Criteria.where("phone_idfa").is(userEntity.getPhone_idfa()));
        }

        if(userEntity.getLast_ip()!=null){
            criteriaList.add(Criteria.where("last_ip").is(userEntity.getLast_ip()));
        }

        if(userEntity.getIsForbid()!=null){
            if(userEntity.getIsForbid().equals("0")){
                criteriaList.add(Criteria.where("forbid_time").lte(0));
            }
            if(userEntity.getIsForbid().equals("1")){
                criteriaList.add(Criteria.where("forbid_time").gt(0));
            }

        }

        Criteria arr[] = new Criteria[criteriaList.size()];
        for (int i =0;i<criteriaList.size();i++){
            arr[i] = criteriaList.get(i);
        }
        if (arr.length>0){
            criteria.andOperator(arr);
        }
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"reg_time"}));
        List<UserEntity> list;
        long total =0;
        if(userEntity.getFlag()!=null&&userEntity.getFlag().equals("clmj")){
            list = fiveMongoTemplate.find(query, UserEntity.class);
            total = fiveMongoTemplate.count(query, UserEntity.class);
        }else {
            list = mongoTemplate.find(query, UserEntity.class);
            total = mongoTemplate.count(query, UserEntity.class);
        };
        for(UserEntity userEntity1:list){
            if(userEntity.getFlag()!=null&&userEntity.getFlag().equals("clmj")) {
                userEntity1.setFlag("clmj");
            }else {
                userEntity1.setFlag("hzmj");
            }
          if(userEntity1.getBank()!=null){
                  userEntity1.setBankgold(userEntity1.getBank().get("bankgold")+"");
                  userEntity1.setBankLevel((Integer) userEntity1.getBank().get("level"));
                  userEntity1.setVip((Integer) userEntity1.getNoble().get("level"));
          }
        }
        Map map=new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
      //  map.put("countData",list3);
        return map;
    }

    @Override
    public Map gameUser4(UserEntity userEntity, Pageable pageable) {
        Query query = new Query();
        query.skip((pageable.getPageNumber())*pageable.getPageSize());
        query.limit(pageable.getPageSize());

        Criteria criteria = new Criteria();
        criteria.and("last_time").gt(DateUtil.getDayEnd().getTime()/1000 -7*24*3600);

        if (userEntity.getUserid()!=null){
            criteria.and("userid").is(userEntity.getUserid());
        }

        if (userEntity.getNickname()!=null){
            String nickname =userEntity.getNickname();
            if(nickname.contains("+")){
                nickname=nickname.replace("+","\\+");
            }
            criteria.and("nickname").regex(nickname);
        }

        List<Criteria> criteriaList = new ArrayList<>();

        if (userEntity.getGold1()!=0 ){
            criteriaList.add(Criteria.where("gold").gte(userEntity.getGold1()));
        }
        if (userEntity.getGold2()!=0 ){
            criteriaList.add(Criteria.where("gold").lte(userEntity.getGold2()));
        }

        if (userEntity.getDiamond1()!=0 ){
            criteriaList.add(Criteria.where("diamond").gte(userEntity.getDiamond1()));
        }

        if (userEntity.getDiamond2()!=0 ){
            criteriaList.add(Criteria.where("diamond").lte(userEntity.getDiamond2()));
        }

        if (userEntity.getBankgold1()!=0 ){
            criteriaList.add(Criteria.where("bank.bankgold").gte(userEntity.getBankgold1()));
        }

        if (userEntity.getBankgold2()!=0 ){
            criteriaList.add(Criteria.where("bank.bankgold").lte(userEntity.getBankgold2()));
        }

        if (userEntity.getQregTime()!=null){
            criteriaList.add(Criteria.where("reg_time").gte(userEntity.getQregTime().get(0).getTime()/1000).lte(userEntity.getQregTime().get(1).getTime()/1000));
        }

        if(userEntity.getMarkNum()>0){
            criteriaList.add(Criteria.where("markNum").is(userEntity.getMarkNum()-1));
        }

        if(userEntity.getPhone_idfa()!=null){
            criteriaList.add(Criteria.where("phone_idfa").is(userEntity.getPhone_idfa()));
        }

        if(userEntity.getLast_ip()!=null){
            criteriaList.add(Criteria.where("last_ip").is(userEntity.getLast_ip()));
        }

        Criteria arr[] = new Criteria[criteriaList.size()];
        for (int i =0;i<criteriaList.size();i++){
            arr[i] = criteriaList.get(i);
        }
        if (arr.length>0){
            criteria.andOperator(arr);
        }

        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"reg_time"}));
        List<UserEntity> list = mongoTemplate.find(query, UserEntity.class);
        for(UserEntity userEntity1:list){
            if(userEntity1.getBank()!=null) {
                userEntity1.setBankgold(userEntity1.getBank().get("bankgold").toString());
                userEntity1.setBankLevel((int) userEntity1.getBank().get("level"));
            }
        }
        long total = mongoTemplate.count(query, UserEntity.class);

        UserEntity userEntity1 = new UserEntity();
        //累计嘻嘻币，累计钻石
        criteria = new Criteria();
        criteria.and("last_time").gt(DateUtil.getDayEnd().getTime()/1000 -7*24*3600);
        if (StringUtils.isNotBlank(userEntity.getUserid())){
            criteria.and("id").is(userEntity.getUserid());
        }

        if (userEntity.getQregTime()!=null){
            criteria.andOperator(Criteria.where("reg_time").gte(userEntity.getQregTime().get(0).getTime()/1000).lte(userEntity.getQregTime().get(1).getTime()/1000));
        }

        Aggregation aggregation =Aggregation.newAggregation(
                match(criteria),
                Aggregation.group().sum("gold").as("gold").sum("diamond").as("diamond").sum("bank.bankgold").as("bankgold")
        );
        AggregationResults<UserEntity> ar=mongoTemplate.aggregate(aggregation,"user",UserEntity.class);
        List<UserEntity> list1=ar.getMappedResults();
        if (list1.size()>0){

            userEntity1.setGold(list1.get(0).getGold());
            userEntity1.setDiamond(list1.get(0).getDiamond());
            userEntity1.setBankgold(list1.get(0).getBankgold());
        }

        //累计封号嘻嘻币，封号钻石
        criteria = new Criteria();
        criteria.and("last_time").gt(DateUtil.getDayEnd().getTime()/1000 -7*24*3600);
        criteria.and("forbid_time").gt(0);
        if (StringUtils.isNotBlank(userEntity.getUserid())){
            criteria.and("id").is(userEntity.getUserid());
        }

        if (userEntity.getQregTime()!=null){
            criteria.andOperator(Criteria.where("reg_time").gte(userEntity.getQregTime().get(0).getTime()/1000).lte(userEntity.getQregTime().get(1).getTime()/1000));
        }
        aggregation = Aggregation.newAggregation(
                Aggregation.match(criteria),
                Aggregation.group().sum("gold").as("gold").sum("diamond").as("diamond")
        );

        ar=mongoTemplate.aggregate(aggregation,"user",UserEntity.class);
        list1=ar.getMappedResults();
        if (list1.size()>0){
            userEntity1.setForbidGold(list1.get(0).getGold().longValue());
            userEntity1.setForbidDiamond(list1.get(0).getDiamond());
        }


        //统计其他邮件奖励
        criteria = new Criteria();
        criteria.and("last_time").gt(DateUtil.getDayEnd().getTime()/1000 -7*24*3600);
        criteria.and("status").is(1);
        criteria.and("mail_type").is(3);
        if (userEntity.getUserid()!=null){
            criteria.and("userId").is(userEntity.getUserid());
        }

        aggregation =Aggregation.newAggregation(
                match(criteria),
                Aggregation.lookup("user","userId","id","emailAwards")
        );
        AggregationResults<CheckListEntity> ar1 =mongoTemplate.aggregate(aggregation,"check_list",CheckListEntity.class);
        List<CheckListEntity> list2=ar1.getMappedResults();
        Double goldsCount = 0.0;
        Double diamondCount = 0.0;
        for(CheckListEntity checkListEntity:list2){
            List<AwardsEntity> awards=new ArrayList<>();
            long regTime=0;
            if(checkListEntity.getEmailAwards().size()>0){
                regTime = checkListEntity.getEmailAwards().get(0).getReg_time();
            }
            if (userEntity.getQregTime()!=null){
                if(regTime>=userEntity.getQregTime().get(0).getTime()/1000 || regTime<=userEntity.getQregTime().get(1).getTime()/1000){
                    awards=checkListEntity.getAwards();
                    if(awards!=null){
                        for(AwardsEntity awardsEntity:awards){
                            int id=awardsEntity.getId();
                            Number num =awardsEntity.getNum();
                            //钻石
                            if(id==100001){
                                diamondCount=diamondCount+num.doubleValue();
                            }
                            //嘻嘻币
                            if(id==100000){
                                goldsCount=goldsCount+num.doubleValue();
                            }

                        }
                    }
                }
            }else{
                awards=checkListEntity.getAwards();
                if(awards!=null){
                    for(AwardsEntity awardsEntity:awards){
                        int id=awardsEntity.getId();
                        Number num =awardsEntity.getNum();
                        //钻石
                        if(id==100001){
                            diamondCount=diamondCount+num.doubleValue();
                        }
                        //嘻嘻币
                        if(id==100000){
                            goldsCount=goldsCount+num.doubleValue();
                        }

                    }
                }
            }

        }

        userEntity1.setGoldsCount(goldsCount.longValue());
        userEntity1.setDiamondCount(diamondCount.longValue());

        List<UserEntity> list3 = new ArrayList<>();
        list3.add(userEntity1);

        Map map=new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        map.put("countData",list3);
        return map;
    }

    @Override
    public boolean updateGameUser(User1Entity userEntity) {
           User1Entity userEntity1;
            if(userEntity.getFlag()!=null&&userEntity.getFlag().equals("clmj")){
                userEntity1 = fiveMongoTemplate.findOne(new Query(Criteria.where("userid").is(userEntity.getUserid())),User1Entity.class);
            }else {
                userEntity1 = mongoTemplate.findOne(new Query(Criteria.where("userid").is(userEntity.getUserid())), User1Entity.class);
            }
            if(userEntity1.getGold()>=userEntity.getGold()||userEntity1.getDiamond()>=userEntity.getDiamond()) {
                Update update = new Update();
                SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM");
                String dateStr = ft.format(new Date()).replace("-", "").trim();
                if (userEntity1.getDiamond() > userEntity.getDiamond()) {
                    String collectionName = "diamond_rec_";
                    collectionName = collectionName + dateStr;
                    DiamondRecEntity diamondRecEntity = new DiamondRecEntity();
                    diamondRecEntity.setDetail(SecurityUtils.getCurrentUsername() + "后台修改");
                    diamondRecEntity.setPid(userEntity.getUserid());
                    diamondRecEntity.setWay("76");
                    diamondRecEntity.setTime(new Date().getTime() / 1000);
                    diamondRecEntity.setBegin_num(userEntity1.getDiamond());
                    diamondRecEntity.setNum(userEntity.getDiamond());
                    if(userEntity1.getChannel().indexOf("cl_")>0) {
                        sixthMongoTemplate.insert(diamondRecEntity, collectionName);
                    }else {
                        secondaryMongoTemplate.insert(diamondRecEntity, collectionName);
                    }
                    update.set("diamond", userEntity.getDiamond());
                }
                if (userEntity1.getGold() > userEntity.getGold()) {
                    String collectionName = "gold_rec_";
                    collectionName = collectionName + dateStr;
                    GoldRecEntity goldRecEntity = new GoldRecEntity();
                    goldRecEntity.setDetail(SecurityUtils.getCurrentUsername() + "后台修改");
                    goldRecEntity.setPid(userEntity.getUserid());
                    goldRecEntity.setWay("76");
                    goldRecEntity.setTime(new Date().getTime() / 1000);
                    goldRecEntity.setBegin_num(userEntity1.getGold().longValue());
                    goldRecEntity.setNum(userEntity.getGold().longValue());
                    if(userEntity1.getChannel().indexOf("cl_")>0) {
                        sixthMongoTemplate.insert(goldRecEntity, collectionName);
                    }else {
                        secondaryMongoTemplate.insert(goldRecEntity, collectionName);
                    }
                    update.set("gold", userEntity.getGold());
                }
                if(userEntity.getBackpack().size()>0) {
                    for (int i = 0; i < userEntity.getBackpack().size(); i++) {
                        if (userEntity1.getBackpack().get(i).getNum() >= userEntity.getBackpack().get(i).getNum()) {
                            String collectionName = "props_rec_";
                            collectionName = collectionName + dateStr;
                            PropsRecEntity propsRecEntity = new PropsRecEntity();
                            propsRecEntity.setDetail(SecurityUtils.getCurrentUsername() + "后台修改数量");
                            propsRecEntity.setPid(userEntity.getUserid());
                            propsRecEntity.setWay("76");
                            propsRecEntity.setTime(new Date().getTime() / 1000);
                            propsRecEntity.setBegin_num(userEntity1.getBackpack().get(i).getNum());
                            propsRecEntity.setChannel(userEntity1.getChannel());
                            propsRecEntity.setName(userEntity1.getBackpack().get(i).getId()+"");
                            propsRecEntity.setNum(userEntity.getBackpack().get(i).getNum() - userEntity1.getBackpack().get(i).getNum());
                            if(userEntity1.getChannel().indexOf("cl_")>0) {
                                sixthMongoTemplate.insert(propsRecEntity, collectionName);
                            }else {
                                secondaryMongoTemplate.insert(propsRecEntity, collectionName);
                            }
                        }else {
                            return false;
                        }
                        if (userEntity.getBackpack().get(i).getEndtime()!=null){
                            if(userEntity1.getBackpack().get(i).getEndtime() >= userEntity.getBackpack().get(i).getEndtime()) {
                            String collectionName = "props_rec_";
                            collectionName = collectionName + dateStr;
                            PropsRecEntity propsRecEntity = new PropsRecEntity();
                            propsRecEntity.setDetail(SecurityUtils.getCurrentUsername() + "后台修改时间");
                            propsRecEntity.setPid(userEntity.getUserid());
                            propsRecEntity.setWay("76");
                            propsRecEntity.setChannel(userEntity1.getChannel());
                            propsRecEntity.setName(userEntity1.getBackpack().get(i).getId()+"");
                            propsRecEntity.setTime(new Date().getTime() / 1000);
                            propsRecEntity.setBegin_num(userEntity1.getBackpack().get(i).getEndtime());
                            propsRecEntity.setNum(userEntity.getBackpack().get(i).getEndtime());
                                if(userEntity1.getChannel().indexOf("cl_")>0) {
                                    sixthMongoTemplate.insert(propsRecEntity, collectionName);
                                }else {
                                    secondaryMongoTemplate.insert(propsRecEntity, collectionName);
                                }

                        }else {
                            return false;}
                        }
                    }
                }
               update.set("backpack",userEntity.getBackpack());
//            update.set("bank.bankgold", userEntity.getBankgold());
//            update.set("playinfo.total",userEntity.getTotal());
//            update.set("playinfo.winc",userEntity.getWinc());
                if(userEntity1.getChannel().indexOf("cl_")>0) {
                    eighthMongoTemplate.updateFirst(new Query(Criteria.where("id").is(userEntity.getUserid())), update, "user");
                }
                else{
                    fourthMongoTemplate.updateFirst(new Query(Criteria.where("id").is(userEntity.getUserid())), update, "user");
                }
                return true;
            }
        return false;
    }

    public List<SysDictDetail> getDictId(long dictId){
        QueryWrapper<SysDictDetail> wrapper=new QueryWrapper<>();
        wrapper.eq("dict_id",dictId);
        List<SysDictDetail> list =sysDictDetailMapper.selectList(wrapper);
        return list;
    }

    @Override
    public void sendEmail(CheckListEntity checkListEntity) {
        List<SysDictDetail> propsDictDictList = getDictId(10);
        String awardsContent="";
        awardsContent=checkListEntity.getContent();
        if(checkListEntity.getMail_stype()==3){
            checkListEntity.setAwards(null);

        }else{
            List<AwardsEntity> awards =checkListEntity.getAwards();
            for(AwardsEntity awardsEntity:awards){
                String id =String.valueOf(awardsEntity.getId());
                if(id.equals("0")||StringUtils.isEmpty(id)){
                    checkListEntity.setAwards(null);
                }else {
                    String name = "";
                    String num = awardsEntity.getNum() + "";
                    for (SysDictDetail SysDictDetail : propsDictDictList) {
                        if (id.equals(SysDictDetail.getValue())) {
                            name = SysDictDetail.getLabel();
                            awardsContent += id + name + ":" + num + ",";
                        }
                    }
                }
            }
        }
        checkListEntity.setStatus("0");
        checkListEntity.setAwardsContent(awardsContent);
        checkListEntity.setSubmit_time((int) (new Date().getTime()/1000));
        checkListEntity.setSubmit_userName(SecurityUtils.getCurrentUsername());
        checkListEntity.setSubmit_userId(SecurityUtils.getCurrentUserId().toString());
        if(checkListEntity.getMailTime()!=null){
            checkListEntity.setBegin_time(checkListEntity.getMailTime().get(0).getTime()/1000-8*3600);
            checkListEntity.setEnd_time(checkListEntity.getMailTime().get(1).getTime()/1000-8*3600);
        }
        fourthMongoTemplate.insert(checkListEntity);
    }

    @Override
    public void forbidUser(UserEntity userEntity) throws IOException {
        String id = userEntity.getUserid();
        long forbidBeginTime=0;
        long forbidTime=0;
        String forbid_reason=userEntity.getForbid_reason();
        String forbidUserid = SecurityUtils.getCurrentUserId()+"";
        String forbidUserName =SecurityUtils.getCurrentUsername();
        if(userEntity.getIsForever()==1){
            forbidBeginTime=new Date().getTime()/1000;
            forbidTime=2145801600;
            forbidMatch(id,forbidBeginTime,forbidTime,forbid_reason,forbidUserid,forbidUserName,userEntity.getFlag());
        }else{
            forbidBeginTime=userEntity.getForbidTime().get(0).getTime()/1000;
            forbidTime=userEntity.getForbidTime().get(1).getTime()/1000;
            forbidMatch(id,forbidBeginTime,forbidTime,forbid_reason,forbidUserid,forbidUserName,userEntity.getFlag());
        }
    }


    @Override
    public void openUser(String userid,String flag) throws IOException {
        long forbidBeginTime=0;
        long forbidTime=0;
        String forbid_reason="";
        String forbidUserid = SecurityUtils.getCurrentUserId()+"";
        String forbidUserName =SecurityUtils.getCurrentUsername();
        forbidMatch(userid,forbidBeginTime,forbidTime,forbid_reason,forbidUserid,forbidUserName,flag);
    }

    public void forbidMatch(String id,long forbidBeginTime,long forbidTime,String forbid_reason,String forbidUserid ,String forbidUserName,String flag) throws IOException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("p_id",id);
        jsonObject.put("forbidBeginTime",forbidBeginTime);
        jsonObject.put("forbidTime",forbidTime);
        jsonObject.put("forbid_reason",forbid_reason);
        jsonObject.put("forbidUserid",forbidUserid);
        jsonObject.put("forbidUserName",forbidUserName);
        JSONObject map = new JSONObject();
        map.put("cmd","set_player_forbid");
        map.put("args",jsonObject);
        String result = null;
        if(flag.equals("hzmj")) {
            result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(), "utf-8");
        }else {
            result = HttpUtil.post(RequestConfig.baseRequestUrl2, map.toJSONString(), "utf-8");
        }
    }

    @Override
    public void frame(String userid,int frame) throws IOException{
//        int[] st={frame};
//        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("ma","ma_hall_frame");
//        jsonObject.put("interface","hall_frame_settle");
//        jsonObject.put("nid",userid);
//        jsonObject.put("arglist",st);
//        JSONObject map = new JSONObject();
//        map.put("cmd","ma_interface_test");
//        map.put("args",jsonObject);
//        String result = null;
//        result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
//        System.out.println(result);
        if(frame>0&&frame<=1000000) {
            Update update = new Update();
            update.set("hall_frame.seg_prestige", frame);
            update.set("hall_frame.prestige", frame);
            update.set("hall_frame.max_prestige", frame);
            fourthMongoTemplate.updateFirst(new Query(Criteria.where("userid").is(userid)), update, UserEntity.class);
        }

    }

    @Override
    public void signUser(UserEntity userEntity) throws IOException {
        if(userEntity.getMarkNum()>0) {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("p_id", userEntity.getUserid());
            jsonObject.put("markNum", userEntity.getMarkNum() - 1);
            JSONObject map = new JSONObject();
            map.put("cmd", "set_player_markNum");
            map.put("args", jsonObject);
            if(userEntity.getFlag().equals("clmj")){
                 HttpUtil.post(RequestConfig.baseRequestUrl2, map.toJSONString(),"utf-8");
            }else {
                 HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
            }
        }
        Update update = new Update();
        update.set("signUserName",SecurityUtils.getCurrentUsername());
        update.set("signUserid",SecurityUtils.getCurrentUserId()+"");
        update.set("signUserTime",new Date().getTime()/1000+"");
        if(userEntity.getVip()!=null&&userEntity.getVip()>0){
           update.set("noble.exp",userEntity.getVip());
        }if(userEntity.getLive_match_flag()!=null&&userEntity.getLive_match_flag()>0){
            update.set("live_match_flag",userEntity.getLive_match_flag()-1);
        }
        System.out.println(userEntity);
        if(userEntity.getFlag().equals("clmj")){
            eighthMongoTemplate.updateFirst(new Query().addCriteria(Criteria.where("id").is(userEntity.getUserid())),update,"user");
        }else {
            fourthMongoTemplate.updateFirst(new Query().addCriteria(Criteria.where("id").is(userEntity.getUserid())),update,"user");
        }
    }

    @Override
    public void cancelUser(UserEntity userEntity) throws IOException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("pid",userEntity.getUserid());
        JSONObject map = new JSONObject();
        map.put("cmd","disable_user");
        map.put("args",jsonObject);
        String result = null;
        if(userEntity.getFlag().equals("clmj")){
           result = HttpUtil.post(RequestConfig.baseRequestUrl2, map.toJSONString(),"utf-8");
        }else {
            result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
        }
    }

    @Override
    public void cancelSign(UserEntity userEntity) throws IOException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("p_id",userEntity.getUserid());
        jsonObject.put("markNum",userEntity.getMarkNum());
        JSONObject map = new JSONObject();
        map.put("cmd","set_player_markNum");
        map.put("args",jsonObject);
        String result = null;
        if(userEntity.getFlag().equals("clmj")){
            result = HttpUtil.post(RequestConfig.baseRequestUrl2, map.toJSONString(),"utf-8");
        }else {
            result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
        }
        Update update = new Update();
        update.set("signUserName","");
        update.set("signUserid","");
        update.set("signUserTime",new Date().getTime()/1000+"");
        if(userEntity.getFlag().equals("clmj")){
            eighthMongoTemplate.updateFirst(new Query(Criteria.where("userid").is(userEntity.getUserid())),update,UserEntity.class);
        }else {
            fourthMongoTemplate.updateFirst(new Query(Criteria.where("userid").is(userEntity.getUserid())),update,UserEntity.class);
        }

    }

    @Override
    public void inningsLimit(UserEntity userEntity) throws IOException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("num",userEntity.getNum());
        JSONObject map = new JSONObject();
        map.put("cmd","setMarkMatchNum");
        map.put("args",jsonObject);
        String result = null;
        if(userEntity.getFlag().equals("clmj")){
            result = HttpUtil.post(RequestConfig.baseRequestUrl2, map.toJSONString(),"utf-8");
        }else {
            result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
        }
    }

    @Override
    public void inningsWin(JSONObject jsonObject) throws IOException {
        String flag= jsonObject.getString("flag");
        Integer v=Integer.parseInt(jsonObject.getString("roomType")) ;
        Map object=(Map)jsonObject.get("playinfo");
        object.put("total", Integer.parseInt(object.get("total").toString()) +Integer.parseInt(jsonObject.get("total").toString())) ;
        object.put("winc", Integer.parseInt(object.get("winc").toString()) +Integer.parseInt(jsonObject.get("winc").toString())) ;
        List list= (List)object.get("gameTypec");
        List list1=new ArrayList();
        for (int i=0;i<list.size();i++){
            if(i==v-1){
                Map map=(Map)list.get(i);
                map.put("total",Integer.parseInt(map.get("total").toString())+Integer.parseInt(jsonObject.get("total").toString()));
                map.put("winc",Integer.parseInt(map.get("winc").toString())+Integer.parseInt(jsonObject.get("winc").toString()));
                list1.add(map);
            }else {
             list1.add(list.get(i));
            }
        }
        object.put("gameTypec",list1);
        Update update = new Update();
        update.set("playinfo",object);
        if(flag.equals("hzmj"))
        {
            fourthMongoTemplate.updateFirst(new Query(Criteria.where("id").is(jsonObject.getString("userid"))),update,"user");
        }
        else {
            eighthMongoTemplate.updateFirst(new Query(Criteria.where("id").is(jsonObject.getString("userid"))),update,"user");
        }
    }

    @Override
    public String robotSwitch() throws IOException {
        JSONObject jsonObject = new JSONObject();
        JSONObject map = new JSONObject();
        map.put("cmd","NO_OFF_use_robot");
        map.put("args",jsonObject);
        String result = null;
        result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");

        Map resultMap = (Map) JSONObject.parse(result);
        return resultMap.get("use_robot").toString();
    }

    @Override
    public void markGold(UserEntity userEntity) throws IOException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("num",userEntity.getMarkNum());
        JSONObject map = new JSONObject();
        map.put("cmd","change_markGold");
        map.put("args",jsonObject);
        String result = null;
        if(userEntity.getFlag().equals("clmj")){
            result = HttpUtil.post(RequestConfig.baseRequestUrl2, map.toJSONString(),"utf-8");
        }else {
            result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
        }
        System.out.println(result);
    }

    @Override
    public Map goldRecord(GoldRecEntity goldRecEntity, Pageable pageable) {
        List<SysDictDetail> sessionsDictList =getDictId(11);
        List<SysDictDetail> tujingDictDictList =getDictId(12);
        Map sessionsDictMap = new HashMap();
        Map tujingDictMap = new HashMap();
        for(SysDictDetail sysDictDetail:sessionsDictList){
            sessionsDictMap.put(sysDictDetail.getValue(),sysDictDetail.getLabel());
        }
        for(SysDictDetail sysDictDetail:tujingDictDictList){
            tujingDictMap.put(sysDictDetail.getValue(),sysDictDetail.getLabel());
        }

        Query query = new Query();
        List<Criteria> criteriaList = new ArrayList<>();
        Criteria criteria = new Criteria();
        if (goldRecEntity.getPid()!=null){
            criteriaList.add(Criteria.where("pid").is(goldRecEntity.getPid()));
        }
        if(goldRecEntity.getWay()!=null){
            criteriaList.add(Criteria.where("way").is(Integer.valueOf(goldRecEntity.getWay())));
        }

        if(goldRecEntity.getDetail()!=null){
            criteriaList.add(Criteria.where("detail").regex(goldRecEntity.getDetail()));
        }

        if(goldRecEntity.getNum1()!=0){
            criteriaList.add(Criteria.where("num").gte(goldRecEntity.getNum1()));
        }

        if(goldRecEntity.getNum2()!=0){
            criteriaList.add(Criteria.where("num").lte(goldRecEntity.getNum2()));
        }

        if(goldRecEntity.getQTime()!=null){
            criteriaList.add(Criteria.where("time").gte(goldRecEntity.getQTime().get(0).getTime()/1000).lte(goldRecEntity.getQTime().get(1).getTime()/1000));
        }

        if(goldRecEntity.getBeginTime()!=null){
            criteriaList.add(Criteria.where("time").gte(goldRecEntity.getBeginTime().getTime()/1000));
        }

         if(goldRecEntity.getEndTime()!=null){
            criteriaList.add(Criteria.where("time").lte(goldRecEntity.getEndTime().getTime()/1000));
        }
        Criteria arr[] = new Criteria[criteriaList.size()];
        for (int i =0;i<criteriaList.size();i++){
            arr[i] = criteriaList.get(i);
        }
        if (arr.length>0){
            criteria.andOperator(arr);
        }
        if(!CollectionUtils.isEmpty(goldRecEntity.getDeptIds())){
            List<Long> deptIds= new ArrayList<>(goldRecEntity.getDeptIds());
            List<SysUser> channels = sysUserMapper.getUserNames(deptIds);
            String channel[] = new String[channels.size()];
            for(int i=0; i<channels.size();i++){
                channel[i]=channels.get(i).getUsername();
            }
            criteria.and("channel").in(channel);
        }
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"time"}));
        List<GoldRecEntity> list = null;
        long total = 0;
        String collectionName="gold_rec_";
        SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM");
        String dateStr= ft.format(new Date());
        if (goldRecEntity.getBeginTime()!=null){
            long time =goldRecEntity.getBeginTime().getTime()/1000;
            String qTime = DateUtil.timeStamp2Date(time+"","yyyy-MM-dd ");
            qTime=qTime.replace("-","").trim().substring(0,6);
            collectionName=collectionName+qTime;
        }else{
            dateStr=dateStr.replace("-","").trim();
            collectionName=collectionName+dateStr;
        }
        if(goldRecEntity.getFlag()!=null&&goldRecEntity.getFlag().equals("clmj")) {
            total = sixthMongoTemplate.count(query, GoldRecEntity.class, collectionName);
            query.skip((pageable.getPageNumber()) * pageable.getPageSize());
            query.limit(pageable.getPageSize());

            list = sixthMongoTemplate.find(query, GoldRecEntity.class, collectionName);
        }else {
            total = secondaryMongoTemplate.count(query, GoldRecEntity.class, collectionName);
            query.skip((pageable.getPageNumber()) * pageable.getPageSize());
            query.limit(pageable.getPageSize());

            list = secondaryMongoTemplate.find(query, GoldRecEntity.class, collectionName);
        }
        Map map =new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        map.put("xData",sessionsDictMap);
        map.put("chartData",tujingDictMap);

        return map;
    }

    @Override
    public Map diamondRecord(DiamondRecEntity diamondRecEntity, Pageable pageable) {
        List<SysDictDetail> tujingDictDictList =getDictId(12);
        Map tujingDictMap = new HashMap();
        for(SysDictDetail sysDictDetail:tujingDictDictList){
            tujingDictMap.put(sysDictDetail.getValue(),sysDictDetail.getLabel());
        }
        Query query = new Query();
        List<Criteria> criteriaList = new ArrayList<>();
        Criteria criteria = new Criteria();
        if (diamondRecEntity.getPid()!=null){
            criteriaList.add(Criteria.where("pid").is(diamondRecEntity.getPid()));
        }
        if(diamondRecEntity.getWay()!=null){
            criteriaList.add(Criteria.where("way").is(Integer.valueOf(diamondRecEntity.getWay())));
        }

        if(diamondRecEntity.getDetail()!=null){
            criteriaList.add(Criteria.where("detail").regex(diamondRecEntity.getDetail()));
        }

        if(diamondRecEntity.getNum1()!=0){
            criteriaList.add(Criteria.where("num").gte(diamondRecEntity.getNum1()));
        }

        if(diamondRecEntity.getNum2()!=0){
            criteriaList.add(Criteria.where("num").lte(diamondRecEntity.getNum2()));
        }

        if(diamondRecEntity.getQTime()!=null){
            criteriaList.add(Criteria.where("time").gte(diamondRecEntity.getQTime().get(0).getTime()/1000).lte(diamondRecEntity.getQTime().get(1).getTime()/1000));
        }

        if(diamondRecEntity.getBeginTime()!=null){
            criteriaList.add(Criteria.where("time").gte(diamondRecEntity.getBeginTime().getTime()/1000));
        }

        if(diamondRecEntity.getEndTime()!=null){
            criteriaList.add(Criteria.where("time").lte(diamondRecEntity.getEndTime().getTime()/1000));
        }
        if(!CollectionUtils.isEmpty(diamondRecEntity.getDeptIds())){
            List<Long> deptIds= new ArrayList<>(diamondRecEntity.getDeptIds());
            List<SysUser> channels = sysUserMapper.getUserNames(deptIds);
            String channel[] = new String[channels.size()];
            for(int i=0; i<channels.size();i++){
                channel[i]=channels.get(i).getUsername();
            }
            criteriaList.add(Criteria.where("channel").in(channel));
        }

        Criteria arr[] = new Criteria[criteriaList.size()];
        for (int i =0;i<criteriaList.size();i++){
            arr[i] = criteriaList.get(i);
        }
        if (arr.length>0){
            criteria.andOperator(arr);
        }

        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"time"}));
        List<DiamondRecEntity> list = null;
        long total = 0;
        String collectionName="diamond_rec_";
        SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM");
        String dateStr= ft.format(new Date());
        if(diamondRecEntity.getBeginTime()!=null){
            long time = diamondRecEntity.getBeginTime().getTime()/1000;
            String qTime = DateUtil.timeStamp2Date(time+"","yyyy-MM-dd ");
            qTime=qTime.replace("-","").trim().substring(0,6);
            collectionName=collectionName+qTime;

        }else{
            dateStr=dateStr.replace("-","").trim();
            collectionName=collectionName+dateStr;

        }
        if(diamondRecEntity.getFlag()==null||diamondRecEntity.getFlag().equals("hzmj")){
            total = secondaryMongoTemplate.count(query, DiamondRecEntity.class, collectionName);
            query.skip((pageable.getPageNumber()) * pageable.getPageSize());
            query.limit(pageable.getPageSize());
            list = secondaryMongoTemplate.find(query, DiamondRecEntity.class, collectionName);
        }
        else {
            total = sixthMongoTemplate.count(query, DiamondRecEntity.class, collectionName);
            query.skip((pageable.getPageNumber()) * pageable.getPageSize());
            query.limit(pageable.getPageSize());
            list = sixthMongoTemplate.find(query, DiamondRecEntity.class, collectionName);
        }
        Map map =new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        map.put("countData",tujingDictMap);
        return map;
    }

    @Autowired
    private DiamondCountMapper diamondCountMapper;

    @Override
    public Map dimondCount(DiamondCount diamondCount, Pageable pageable) {
        Page<DiamondCount> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<DiamondCount> wrapper =new QueryWrapper<>();
        if(diamondCount.getQTime()!=null){
            wrapper.ge("time",diamondCount.getQTime().get(0).getTime()/1000);
            wrapper.le("time",diamondCount.getQTime().get(1).getTime()/1000);
        }
        wrapper.eq("channel","total").or().isNull("channel");
        wrapper.orderBy(true,false,"time");

        IPage<DiamondCount> ipage = diamondCountMapper.selectPage(page,wrapper);
        List<DiamondCount> list = ipage.getRecords();
        long total = ipage.getTotal();
        Map map =new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        return map;
    }

    @Override
    public Map propsCount(UserEntity userEntity, Pageable pageable) {
        List<SysDictDetail> propsDictDictList =getDictId( 10);
        List<PropsEntity> list = new ArrayList<>();
        Criteria criteria = new Criteria();
        if (userEntity.getQTime()!=null){
            criteria.andOperator(Criteria.where("last_time").gte(userEntity.getQTime().get(0).getTime()/1000).lte(userEntity.getQTime().get(1).getTime()/1000));
        }

        //嘻嘻币
        Aggregation aggregation=Aggregation.newAggregation(
                match(criteria),
                Aggregation.group().sum("gold").as("count")
        );
        AggregationResults<PropsEntity> ar = mongoTemplate.aggregate(aggregation, "user", PropsEntity.class);
        List<PropsEntity> list1 = ar.getMappedResults();
        if(list1.size() > 0){
            list1.get(0).setPropsName("嘻嘻币");
        }
        list.addAll(list1);

        //钻石
        aggregation=Aggregation.newAggregation(
                match(criteria),
                Aggregation.group().sum("diamond").as("count")
        );
        ar = mongoTemplate.aggregate(aggregation, "user", PropsEntity.class);

        List<PropsEntity> list2 = ar.getMappedResults();
        if(list2.size() > 0){
            list2.get(0).setPropsName("钻石");
        }
        list.addAll(list2);

        Map map =new HashMap();
        map.put("content",list);
        map.put("totalElements",propsDictDictList.size());
        return map;
    }

    @Override
    public Map bankGoldRecord(BankGoldRecEntity bankGoldRecEntity, Pageable pageable) {
        List<SysDictDetail> sessionsDictList =getDictId((long) 11);
        List<SysDictDetail> tujingDictDictList =getDictId((long) 12);
        Map sessionsDictMap = new HashMap();
        Map tujingDictMap = new HashMap();
        for(SysDictDetail sysDictDetail:sessionsDictList){
            sessionsDictMap.put(sysDictDetail.getValue(),sysDictDetail.getLabel());
        }
        for(SysDictDetail sysDictDetail:tujingDictDictList){
            tujingDictMap.put(sysDictDetail.getValue(),sysDictDetail.getLabel());
        }
        Query query = new Query();
        query.skip((pageable.getPageNumber())*pageable.getPageSize());
        query.limit(pageable.getPageSize());
        List<Criteria> criteriaList = new ArrayList<>();
        Criteria criteria = new Criteria();
        if (bankGoldRecEntity.getPid()!=null){
            criteriaList.add(Criteria.where("pid").is(bankGoldRecEntity.getPid()));
        }
        if(bankGoldRecEntity.getWay()!=null){
            criteriaList.add(Criteria.where("way").is(Integer.valueOf(bankGoldRecEntity.getWay())));
        }

        if(bankGoldRecEntity.getDetail()!=null){
            criteriaList.add(Criteria.where("detail").regex(bankGoldRecEntity.getDetail()));
        }

        if(bankGoldRecEntity.getNum1()!=0){
            criteriaList.add(Criteria.where("num").gte(bankGoldRecEntity.getNum1()));
        }

        if(bankGoldRecEntity.getNum2()!=0){
            criteriaList.add(Criteria.where("num").lte(bankGoldRecEntity.getNum2()));
        }

        if(bankGoldRecEntity.getQTime()!=null){
            criteriaList.add(Criteria.where("time").gte(bankGoldRecEntity.getQTime().get(0).getTime()/1000).lte(bankGoldRecEntity.getQTime().get(1).getTime()/1000));
        }
        if(bankGoldRecEntity.getBeginTime()!=null){
            criteriaList.add(Criteria.where("time").gte(bankGoldRecEntity.getBeginTime().getTime()/1000));
        }
        if(bankGoldRecEntity.getEndTime()!=null){
            criteriaList.add(Criteria.where("time").lte(bankGoldRecEntity.getEndTime().getTime()/1000));
        }

        Criteria arr[] = new Criteria[criteriaList.size()];
        for (int i =0;i<criteriaList.size();i++){
            arr[i] = criteriaList.get(i);
        }
        if (arr.length>0){
            criteria.andOperator(arr);
        }

        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"time"}));
        List<BankGoldRecEntity> list = null;
        long total = 0;
        String collectionName="bankgold_rec_";
        SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM");
        String dateStr= ft.format(new Date());
        if (bankGoldRecEntity.getBeginTime()!=null){
            long time =bankGoldRecEntity.getBeginTime().getTime()/1000;
            String qTime = DateUtil.timeStamp2Date(time+"","yyyy-MM-dd ");
            qTime=qTime.replace("-","").trim().substring(0,6);
            collectionName=collectionName+qTime;
        }else{
            dateStr=dateStr.replace("-","").trim();
            collectionName=collectionName+dateStr;
        }

        list = secondaryMongoTemplate.find(query,BankGoldRecEntity.class,collectionName);
        total = secondaryMongoTemplate.count(query,BankGoldRecEntity.class,collectionName);
        System.out.println(list);
        Map map =new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        map.put("xData",sessionsDictMap);
        map.put("chartData",tujingDictMap);

        return map;
    }
    @Autowired
    private BankInfoMapper bankInfoMapper;

    @Autowired
    private RedisUtils redisUtils;

    @Override
    public Map bankInfo(BankInfoEntity bankInfoEntity, Pageable pageable){
        Page<BankInfoEntity> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<BankInfoEntity> wrapper =new QueryWrapper<>();
        wrapper.orderByAsc("level");
        IPage<BankInfoEntity> ipage = bankInfoMapper.selectPage(page,wrapper);
        List<BankInfoEntity> phoneInfolist = ipage.getRecords();
        long total = ipage.getTotal();
        Map map =new HashMap();
        map.put("list",phoneInfolist);
        map.put("total",total);
        return map;
    }


    @Override
    public Map propsRecord(PropsRecEntity propsRecEntity, Pageable pageable) {
        List<SysDictDetail> propsDictDictList =getDictId(10);
        List<SysDictDetail> tujingDictDictList =getDictId(12);
        Map propsDictMap = new HashMap();
        for(SysDictDetail sysDictDetail:propsDictDictList){
            propsDictMap.put(sysDictDetail.getValue(),sysDictDetail.getLabel());
        }

        Map tujingDictMap = new HashMap();
        for(SysDictDetail sysDictDetail:tujingDictDictList){
            tujingDictMap.put(sysDictDetail.getValue(),sysDictDetail.getLabel());
        }

        Query query = new Query();
        query.skip((pageable.getPageNumber())*pageable.getPageSize());
        query.limit(pageable.getPageSize());
        List<Criteria> criteriaList = new ArrayList<>();
        Criteria criteria = new Criteria();
        if (propsRecEntity.getPid()!=null){
            criteriaList.add(Criteria.where("pid").is(propsRecEntity.getPid()));
        }

        if (propsRecEntity.getName()!=null){
            criteriaList.add(Criteria.where("name").is(Integer.parseInt(propsRecEntity.getName())));
        }

        if(propsRecEntity.getWay()!=null){
            criteriaList.add(Criteria.where("way").is(Integer.valueOf(propsRecEntity.getWay())));
        }

        if(propsRecEntity.getDetail()!=null){
            criteriaList.add(Criteria.where("detail").regex(propsRecEntity.getDetail()));
        }

        if(propsRecEntity.getNum1()!=0){
            criteriaList.add(Criteria.where("num").gte(propsRecEntity.getNum1()));
        }

        if(propsRecEntity.getNum2()!=0){
            criteriaList.add(Criteria.where("num").lte(propsRecEntity.getNum2()));
        }

        if(propsRecEntity.getQTime()!=null){
            criteriaList.add(Criteria.where("time").gte(propsRecEntity.getQTime().get(0).getTime()/1000).lte(propsRecEntity.getQTime().get(1).getTime()/1000));
        }

        if(propsRecEntity.getBeginTime()!=null){
            criteriaList.add(Criteria.where("time").gte(propsRecEntity.getBeginTime().getTime()/1000));
        }

        if(propsRecEntity.getEndTime()!=null){
            criteriaList.add(Criteria.where("time").lte(propsRecEntity.getEndTime().getTime()/1000));
        }
        if(!CollectionUtils.isEmpty(propsRecEntity.getDeptIds())){
            List<Long> deptIds= new ArrayList<>(propsRecEntity.getDeptIds());
            List<SysUser> channels = sysUserMapper.getUserNames(deptIds);
            String channel[] = new String[channels.size()];
            for(int i=0; i<channels.size();i++){
                channel[i]=channels.get(i).getUsername();
            }
            criteriaList.add(Criteria.where("channel").in(channel));
        }
        Criteria arr[] = new Criteria[criteriaList.size()];
        for (int i =0;i<criteriaList.size();i++){
            arr[i] = criteriaList.get(i);
        }
        if (arr.length>0){
            criteria.andOperator(arr);
        }

        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"time"}));
        List<PropsRecEntity> list = null;
        long total = 0;
        String collectionName="props_rec_";
        SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM");
        String dateStr= ft.format(new Date());
        if (propsRecEntity.getBeginTime()!=null){
            long time =propsRecEntity.getBeginTime().getTime()/1000;
            String qTime = DateUtil.timeStamp2Date(time+"","yyyy-MM-dd ");
            qTime=qTime.replace("-","").trim().substring(0,6);
            collectionName=collectionName+qTime;
        }else{
            dateStr=dateStr.replace("-","").trim();
            collectionName=collectionName+dateStr;

        }
        if(propsRecEntity.getFlag()==null||propsRecEntity.getFlag().equals("hzmj")) {
            list = secondaryMongoTemplate.find(query, PropsRecEntity.class, collectionName);
            total = secondaryMongoTemplate.count(query, PropsRecEntity.class, collectionName);
        }else {
            list = sixthMongoTemplate.find(query, PropsRecEntity.class, collectionName);
            total = sixthMongoTemplate.count(query, PropsRecEntity.class, collectionName);
        }
        Map map =new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        map.put("xData",propsDictMap);
        map.put("chartData",tujingDictMap);
        return map;
    }

    @Autowired
    BindPlayerMapper bindPlayerMapper;

    @Override
    public Map bindPlayers(BindPlayer bindPlayer, Pageable pageable) {
        Page<BindPlayer> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<BindPlayer> wrapper =new QueryWrapper<>();
        wrapper.orderByDesc("bind_num");
        if (bindPlayer.getUserId()!=null){
            wrapper.eq("user_id",bindPlayer.getUserId());
        }
        if (bindPlayer.getChannel()!=null){
            wrapper.eq("channel",bindPlayer.getChannel());
        }
        //绑定玩家总数量
        IPage<BindPlayer> ipage = bindPlayerMapper.selectPage(page,wrapper);
        List<BindPlayer> list = ipage.getRecords();
        List<BindPlayer> list1=bindPlayerMapper.getBindList(bindPlayer);

        Map map=new HashMap();
        map.put("content",list);
        map.put("totalElements",ipage.getTotal());
        map.put("countData",list1);
        return map;
    }

    @Autowired
    ShareSeatMapper shareSeatMapper;

    @Override
    public Map getShareSeat(ShareSeat shareSeat,Pageable pageable)throws IOException{
        Page<ShareSeat> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<ShareSeat> wrapper =new QueryWrapper<>();
        wrapper.orderByDesc("time");
        if(shareSeat.getQTime()!=null){
            wrapper.ge("time",shareSeat.getQTime().get(0).getTime()/1000);
            wrapper.le("time",shareSeat.getQTime().get(1).getTime()/1000);
        }
        if(shareSeat.getChannel()!=null){
            wrapper.eq("channel",shareSeat.getChannel());
        }else{
            wrapper.eq("channel","total").or().isNull("channel");

        }
        if(shareSeat.getTime()!=null&&shareSeat.getTime()>0){
            wrapper.eq("time",shareSeat.getTime());
            wrapper.ne("channel","total");
        }
        IPage<ShareSeat> ipage = shareSeatMapper.selectPage(page,wrapper);
        List<ShareSeat> list = ipage.getRecords();
        long total = ipage.getTotal();
        Map map=new HashMap();
        map.put("content",list);
        map.put("totalElements",total);
        return map;
    }

    @Override
    public List<ShareSeat> getShareSeat(Integer time){
        QueryWrapper<ShareSeat> wrapper =new QueryWrapper<>();
        if(time!=null&&time>0){
            wrapper.eq("time",time);
            wrapper.ne("channel","total");
        }
        wrapper.orderBy(true,false,"id");
        List<ShareSeat> list = shareSeatMapper.selectList(wrapper);
        if(list.size()>0){
            for(ShareSeat shareSeat:list){
                shareSeat.setHasChildren(false);
            }
        }
        return list;
    }

    @Autowired
    RoomsUserInfoMapper roomsUserInfoMapper;

    @Override
    public Map getRoomsList(RoomsUserInfo roomsUserInfo,Pageable pageable)throws IOException{
        Page<RoomsUserInfo> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<RoomsUserInfo> wrapper =new QueryWrapper<>();
       if(StringUtils.isNotBlank(roomsUserInfo.getChannel())){
           wrapper.eq("channel",roomsUserInfo.getChannel());
           if(roomsUserInfo.getChannel().equals("h5hzmjxl_wechat")){
               wrapper.eq("the_father","hzmjxl_total");
           }
       }else {
           wrapper.isNull("the_father");
       }
        wrapper.orderByDesc("create_time");
        IPage<RoomsUserInfo> ipage = roomsUserInfoMapper.selectPage(page,wrapper);
        List<RoomsUserInfo> phoneInfolist = ipage.getRecords();
        Page<BrokeInfo> page1 = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<BrokeInfo> wrapper1 =new QueryWrapper<>();
        if(StringUtils.isNotBlank(roomsUserInfo.getChannel())){
            wrapper1.eq("channel",roomsUserInfo.getChannel());
        }else {
            wrapper1.isNull("the_father");
        }
        wrapper1.orderByDesc("time");
        List<BrokeInfo> list = brokeInfoMapper.selectPage(page1,wrapper1).getRecords();
       if(phoneInfolist.size()>0){
        for (RoomsUserInfo roomsUserInfo1:phoneInfolist){
            Integer[] j = new Integer[57];
            roomsUserInfo1.setBroke(j);
            roomsUserInfo1.setBrokeBuy(j);
            roomsUserInfo1.setBrokeMoney(j);
            for(int i=0;i<list.size();i++){
                roomsUserInfo1.setValues(JSONObject.parseObject(roomsUserInfo1.getTheValue()));
               if(roomsUserInfo1.getCreateTime().intValue()==list.get(i).getTime()) {
                JSONObject jsonObject=null;
                if(list.get(i).getTheValues()!=null) {
                    jsonObject= JSONObject.parseObject(list.get(i).getTheValues());
                }
                   j = new Integer[57];
                j[0] = list.get(i).getBroke();
                j[1] = list.get(i).getBroke1();
                j[2] = list.get(i).getBroke2();
                j[3] = list.get(i).getBroke3();
                j[4] = list.get(i).getBroke4();
                j[5] = list.get(i).getBroke5();
                j[6] = list.get(i).getBroke6();
                j[7] = list.get(i).getBroke7();
                j[8] = list.get(i).getBroke8();
                j[9] = list.get(i).getBroke9();
                j[10] = list.get(i).getBroke10();
                j[11] = list.get(i).getBroke11();
                j[12] = list.get(i).getBroke12();
                j[13] = list.get(i).getBroke13();
                j[14] = list.get(i).getBroke14();
                j[15] = list.get(i).getBroke15();
                j[16] = list.get(i).getBroke16();
                j[17] = list.get(i).getBroke17();
                j[18] = list.get(i).getBroke18();
                j[19] = list.get(i).getBroke19();
                j[20] = list.get(i).getBroke20();
                j[21] = list.get(i).getBroke21();
                j[22] = list.get(i).getBroke22();
                j[23] = list.get(i).getBroke23();
                j[24] = list.get(i).getBroke24();
                j[25] = list.get(i).getBroke25();
                j[26] = list.get(i).getBroke26();
                j[27] = list.get(i).getBroke27();
                j[28] = list.get(i).getBroke28();
                j[29] = list.get(i).getBroke29();
                j[30] = list.get(i).getBroke30();
                j[31] = list.get(i).getBroke31();
                if(list.get(i).getBroke32()!=null) {
                    j[32] = list.get(i).getBroke32();
                    j[33] = list.get(i).getBroke33();
                    j[34] = list.get(i).getBroke34();
                    j[35] = list.get(i).getBroke35();
                    j[36] = list.get(i).getBroke36();
                    j[37] = list.get(i).getBroke37();
                    j[38] = list.get(i).getBroke38();
                    j[39] = list.get(i).getBroke39();
                    j[40] = list.get(i).getBroke40();
                    j[41] = list.get(i).getBroke41();
                    j[42] = list.get(i).getBroke42();
                    j[43] = list.get(i).getBroke43();
                }
                if(jsonObject!=null){
                    j[44]= (int)jsonObject.getJSONObject("106").get("broke");
                    j[45]= (int)jsonObject.getJSONObject("206").get("broke");
                    j[46]= (int)jsonObject.getJSONObject("306").get("broke");
                    j[47]= (int)jsonObject.getJSONObject("406").get("broke");
                    j[48]= (int)jsonObject.getJSONObject("506").get("broke");
                    j[49]= (int)jsonObject.getJSONObject("606").get("broke");
                    j[50]= (int)jsonObject.getJSONObject("706").get("broke");
                    j[51]= (int)jsonObject.getJSONObject("806").get("broke");
                    j[52]= (int)jsonObject.getJSONObject("906").get("broke");
                    j[53]= (int)jsonObject.getJSONObject("1006").get("broke");
                    j[54]= (int)jsonObject.getJSONObject("1106").get("broke");
                    j[55]= (int)jsonObject.getJSONObject("1206").get("broke");
                    j[56]= (int)jsonObject.getJSONObject("1306").get("broke");
                }
                roomsUserInfo1.setBroke(j);
                j = new Integer[57];
                j[0] = list.get(i).getBrokeBuy();
                j[1] = list.get(i).getBrokeBuy1();
                j[2] = list.get(i).getBrokeBuy2();
                j[3] = list.get(i).getBrokeBuy3();
                j[4] = list.get(i).getBrokeBuy4();
                j[5] = list.get(i).getBrokeBuy5();
                j[6] = list.get(i).getBrokeBuy6();
                j[7] = list.get(i).getBrokeBuy7();
                j[8] = list.get(i).getBrokeBuy8();
                j[9] = list.get(i).getBrokeBuy9();
                j[10] = list.get(i).getBrokeBuy10();
                j[11] = list.get(i).getBrokeBuy11();
                j[12] = list.get(i).getBrokeBuy12();
                j[13] = list.get(i).getBrokeBuy13();
                j[14] = list.get(i).getBrokeBuy14();
                j[15] = list.get(i).getBrokeBuy15();
                j[16] = list.get(i).getBrokeBuy16();
                j[17] = list.get(i).getBrokeBuy17();
                j[18] = list.get(i).getBrokeBuy18();
                j[19] = list.get(i).getBrokeBuy19();
                j[20] = list.get(i).getBrokeBuy20();
                j[21] = list.get(i).getBrokeBuy21();
                j[22] = list.get(i).getBrokeBuy22();
                j[23] = list.get(i).getBrokeBuy23();
                j[24] = list.get(i).getBrokeBuy24();
                j[25] = list.get(i).getBrokeBuy25();
                j[26] = list.get(i).getBrokeBuy26();
                j[27] = list.get(i).getBrokeBuy27();
                j[28] = list.get(i).getBrokeBuy28();
                j[29] = list.get(i).getBrokeBuy29();
                j[30] = list.get(i).getBrokeBuy30();
                j[31] = list.get(i).getBrokeBuy31();
                if(list.get(i).getBroke32()!=null) {
                    j[32] = list.get(i).getBrokeBuy32();
                    j[33] = list.get(i).getBrokeBuy33();
                    j[34] = list.get(i).getBrokeBuy34();
                    j[35] = list.get(i).getBrokeBuy35();
                    j[36] = list.get(i).getBrokeBuy36();
                    j[37] = list.get(i).getBrokeBuy37();
                    j[38] = list.get(i).getBrokeBuy38();
                    j[39] = list.get(i).getBrokeBuy39();
                    j[40] = list.get(i).getBrokeBuy40();
                    j[41] = list.get(i).getBrokeBuy41();
                    j[42] = list.get(i).getBrokeBuy42();
                    j[43] = list.get(i).getBrokeBuy43();
                }
                if(jsonObject!=null){
                    j[44]= (int)jsonObject.getJSONObject("106").get("brokeBuy");
                    j[45]= (int)jsonObject.getJSONObject("206").get("brokeBuy");
                    j[46]= (int)jsonObject.getJSONObject("306").get("brokeBuy");
                    j[47]= (int)jsonObject.getJSONObject("406").get("brokeBuy");
                    j[48]= (int)jsonObject.getJSONObject("506").get("brokeBuy");
                    j[49]= (int)jsonObject.getJSONObject("606").get("brokeBuy");
                    j[50]= (int)jsonObject.getJSONObject("706").get("brokeBuy");
                    j[51]= (int)jsonObject.getJSONObject("806").get("brokeBuy");
                    j[52]= (int)jsonObject.getJSONObject("906").get("brokeBuy");
                    j[53]= (int)jsonObject.getJSONObject("1006").get("brokeBuy");
                    j[54]= (int)jsonObject.getJSONObject("1106").get("brokeBuy");
                    j[55]= (int)jsonObject.getJSONObject("1206").get("brokeBuy");
                    j[56]= (int)jsonObject.getJSONObject("1306").get("brokeBuy");
                }
                roomsUserInfo1.setBrokeBuy(j);
                j = new Integer[57];
                j[0] = list.get(i).getActive();
                j[1] = list.get(i).getActive1();
                j[2] = list.get(i).getActive2();
                j[3] = list.get(i).getActive3();
                j[4] = list.get(i).getActive4();
                j[5] = list.get(i).getActive5();
                j[6] = list.get(i).getActive6();
                j[7] = list.get(i).getActive7();
                j[8] = list.get(i).getActive8();
                j[9] = list.get(i).getActive9();
                j[10] = list.get(i).getActive10();
                j[11] = list.get(i).getActive11();
                j[12] = list.get(i).getActive12();
                j[13] = list.get(i).getActive13();
                j[14] = list.get(i).getActive14();
                j[15] = list.get(i).getActive15();
                j[16] = list.get(i).getActive16();
                j[17] = list.get(i).getActive17();
                j[18] = list.get(i).getActive18();
                j[19] = list.get(i).getActive19();
                j[20] = list.get(i).getActive20();
                j[21] = list.get(i).getActive21();
                j[22] = list.get(i).getActive22();
                j[23] = list.get(i).getActive23();
                j[24] = list.get(i).getActive24();
                j[25] = list.get(i).getActive25();
                j[26] = list.get(i).getActive26();
                j[27] = list.get(i).getActive27();
                j[28] = list.get(i).getActive28();
                j[29] = list.get(i).getActive29();
                j[30] = list.get(i).getActive30();
                j[31] = list.get(i).getActive31();
                if(list.get(i).getBroke32()!=null) {
                    j[32] = list.get(i).getActive32();
                    j[33] = list.get(i).getActive33();
                    j[34] = list.get(i).getActive34();
                    j[35] = list.get(i).getActive35();
                    j[36] = list.get(i).getActive36();
                    j[37] = list.get(i).getActive37();
                    j[38] = list.get(i).getActive38();
                    j[39] = list.get(i).getActive39();
                    j[40] = list.get(i).getActive40();
                    j[41] = list.get(i).getActive41();
                    j[42] = list.get(i).getActive42();
                    j[43] = list.get(i).getActive43();
                }
                if(jsonObject!=null){
                    j[44]= (int)jsonObject.getJSONObject("106").get("money");
                    j[45]= (int)jsonObject.getJSONObject("206").get("money");
                    j[46]= (int)jsonObject.getJSONObject("306").get("money");
                    j[47]= (int)jsonObject.getJSONObject("406").get("money");
                    j[48]= (int)jsonObject.getJSONObject("506").get("money");
                    j[49]= (int)jsonObject.getJSONObject("606").get("money");
                    j[50]= (int)jsonObject.getJSONObject("706").get("money");
                    j[51]= (int)jsonObject.getJSONObject("806").get("money");
                    j[52]= (int)jsonObject.getJSONObject("906").get("money");
                    j[53]= (int)jsonObject.getJSONObject("1006").get("money");
                    j[54]= (int)jsonObject.getJSONObject("1106").get("money");
                    j[55]= (int)jsonObject.getJSONObject("1206").get("money");
                    j[56]= (int)jsonObject.getJSONObject("1306").get("money");
                }
                roomsUserInfo1.setBrokeMoney(j);
             }
            }
          }
       }

        long total = ipage.getTotal();
        Map map=new HashMap();
        map.put("content",phoneInfolist);
        map.put("totalElements",total);
        return map;
    }

    @Override
    public List<RoomsUserInfo> getRoomsList( Integer time,String channel){
        String channel1=channel;
        if(channel.equals("totalcl")){
            channel1="taotacl";
        }
        QueryWrapper<BrokeInfo> wrapper1 =new QueryWrapper<>();
        if(time!=null&&time>0){
            wrapper1.eq("time",time);
            wrapper1.eq("the_father",channel1);
        }
        List<BrokeInfo> list = brokeInfoMapper.selectList(wrapper1);
        QueryWrapper<RoomsUserInfo> wrapper =new QueryWrapper<>();
        if(time!=null&&time>0){
            wrapper.eq("create_time",time);
            wrapper.eq("the_father",channel);
        }
        wrapper.orderBy(true,false,"id");
        List<RoomsUserInfo> list1 = roomsUserInfoMapper.selectList(wrapper);
        if(list1.size()>0){
            for(RoomsUserInfo roomsUserInfo:list1){
                Integer[] j = new Integer[57];
                roomsUserInfo.setBroke(j);
                roomsUserInfo.setBrokeBuy(j);
                roomsUserInfo.setBrokeMoney(j);
                roomsUserInfo.setValues(JSONObject.parseObject(roomsUserInfo.getTheValue()));
                for ( int i=0;i<list.size();i++){
                    if(roomsUserInfo.getChannel().equals(list.get(i).getChannel())&&roomsUserInfo.getCreateTime().intValue()==list.get(i).getTime()) {
                    JSONObject jsonObject=null;
                    if(list.get(i).getTheValues()!=null) {
                        jsonObject= JSONObject.parseObject(list.get(i).getTheValues());
                    }
                        j = new Integer[57];
                    j[0] = list.get(i).getBroke();
                    j[1] = list.get(i).getBroke1();
                    j[2] = list.get(i).getBroke2();
                    j[3] = list.get(i).getBroke3();
                    j[4] = list.get(i).getBroke4();
                    j[5] = list.get(i).getBroke5();
                    j[6] = list.get(i).getBroke6();
                    j[7] = list.get(i).getBroke7();
                    j[8] = list.get(i).getBroke8();
                    j[9] = list.get(i).getBroke9();
                    j[10] = list.get(i).getBroke10();
                    j[11] = list.get(i).getBroke11();
                    j[12] = list.get(i).getBroke12();
                    j[13] = list.get(i).getBroke13();
                    j[14] = list.get(i).getBroke14();
                    j[15] = list.get(i).getBroke15();
                    j[16] = list.get(i).getBroke16();
                    j[17] = list.get(i).getBroke17();
                    j[18] = list.get(i).getBroke18();
                    j[19] = list.get(i).getBroke19();
                    j[20] = list.get(i).getBroke20();
                    j[21] = list.get(i).getBroke21();
                    j[22] = list.get(i).getBroke22();
                    j[23] = list.get(i).getBroke23();
                    j[24] = list.get(i).getBroke24();
                    j[25] = list.get(i).getBroke25();
                    j[26] = list.get(i).getBroke26();
                    j[27] = list.get(i).getBroke27();
                    j[28] = list.get(i).getBroke28();
                    j[29] = list.get(i).getBroke29();
                    j[30] = list.get(i).getBroke30();
                    j[31] = list.get(i).getBroke31();
                    if(list.get(i).getBroke32()!=null) {
                        j[32] = list.get(i).getBroke32();
                        j[33] = list.get(i).getBroke33();
                        j[34] = list.get(i).getBroke34();
                        j[35] = list.get(i).getBroke35();
                        j[36] = list.get(i).getBroke36();
                        j[37] = list.get(i).getBroke37();
                        j[38] = list.get(i).getBroke38();
                        j[39] = list.get(i).getBroke39();
                        j[40] = list.get(i).getBroke40();
                        j[41] = list.get(i).getBroke41();
                        j[42] = list.get(i).getBroke42();
                        j[43] = list.get(i).getBroke43();
                    }
                    if(jsonObject!=null){
                        j[44]= (int)jsonObject.getJSONObject("106").get("broke");
                        j[45]= (int)jsonObject.getJSONObject("206").get("broke");
                        j[46]= (int)jsonObject.getJSONObject("306").get("broke");
                        j[47]= (int)jsonObject.getJSONObject("406").get("broke");
                        j[48]= (int)jsonObject.getJSONObject("506").get("broke");
                        j[49]= (int)jsonObject.getJSONObject("606").get("broke");
                        j[50]= (int)jsonObject.getJSONObject("706").get("broke");
                        j[51]= (int)jsonObject.getJSONObject("806").get("broke");
                        j[52]= (int)jsonObject.getJSONObject("906").get("broke");
                        j[53]= (int)jsonObject.getJSONObject("1006").get("broke");
                        j[54]= (int)jsonObject.getJSONObject("1106").get("broke");
                        j[55]= (int)jsonObject.getJSONObject("1206").get("broke");
                        j[56]= (int)jsonObject.getJSONObject("1306").get("broke");
                    }
                    roomsUserInfo.setBroke(j);
                    j = new Integer[57];
                    j[0] = list.get(i).getBrokeBuy();
                    j[1] = list.get(i).getBrokeBuy1();
                    j[2] = list.get(i).getBrokeBuy2();
                    j[3] = list.get(i).getBrokeBuy3();
                    j[4] = list.get(i).getBrokeBuy4();
                    j[5] = list.get(i).getBrokeBuy5();
                    j[6] = list.get(i).getBrokeBuy6();
                    j[7] = list.get(i).getBrokeBuy7();
                    j[8] = list.get(i).getBrokeBuy8();
                    j[9] = list.get(i).getBrokeBuy9();
                    j[10] = list.get(i).getBrokeBuy10();
                    j[11] = list.get(i).getBrokeBuy11();
                    j[12] = list.get(i).getBrokeBuy12();
                    j[13] = list.get(i).getBrokeBuy13();
                    j[14] = list.get(i).getBrokeBuy14();
                    j[15] = list.get(i).getBrokeBuy15();
                    j[16] = list.get(i).getBrokeBuy16();
                    j[17] = list.get(i).getBrokeBuy17();
                    j[18] = list.get(i).getBrokeBuy18();
                    j[19] = list.get(i).getBrokeBuy19();
                    j[20] = list.get(i).getBrokeBuy20();
                    j[21] = list.get(i).getBrokeBuy21();
                    j[22] = list.get(i).getBrokeBuy22();
                    j[23] = list.get(i).getBrokeBuy23();
                    j[24] = list.get(i).getBrokeBuy24();
                    j[25] = list.get(i).getBrokeBuy25();
                    j[26] = list.get(i).getBrokeBuy26();
                    j[27] = list.get(i).getBrokeBuy27();
                    j[28] = list.get(i).getBrokeBuy28();
                    j[29] = list.get(i).getBrokeBuy29();
                    j[30] = list.get(i).getBrokeBuy30();
                    j[31] = list.get(i).getBrokeBuy31();
                    if(list.get(i).getBroke32()!=null) {
                        j[32] = list.get(i).getBrokeBuy32();
                        j[33] = list.get(i).getBrokeBuy33();
                        j[34] = list.get(i).getBrokeBuy34();
                        j[35] = list.get(i).getBrokeBuy35();
                        j[36] = list.get(i).getBrokeBuy36();
                        j[37] = list.get(i).getBrokeBuy37();
                        j[38] = list.get(i).getBrokeBuy38();
                        j[39] = list.get(i).getBrokeBuy39();
                        j[40] = list.get(i).getBrokeBuy40();
                        j[41] = list.get(i).getBrokeBuy41();
                        j[42] = list.get(i).getBrokeBuy42();
                        j[43] = list.get(i).getBrokeBuy43();
                    }
                    if(jsonObject!=null){
                        j[44]= (int)jsonObject.getJSONObject("106").get("brokeBuy");
                        j[45]= (int)jsonObject.getJSONObject("206").get("brokeBuy");
                        j[46]= (int)jsonObject.getJSONObject("306").get("brokeBuy");
                        j[47]= (int)jsonObject.getJSONObject("406").get("brokeBuy");
                        j[48]= (int)jsonObject.getJSONObject("506").get("brokeBuy");
                        j[49]= (int)jsonObject.getJSONObject("606").get("brokeBuy");
                        j[50]= (int)jsonObject.getJSONObject("706").get("brokeBuy");
                        j[51]= (int)jsonObject.getJSONObject("806").get("brokeBuy");
                        j[52]= (int)jsonObject.getJSONObject("906").get("brokeBuy");
                        j[53]= (int)jsonObject.getJSONObject("1006").get("brokeBuy");
                        j[54]= (int)jsonObject.getJSONObject("1106").get("brokeBuy");
                        j[55]= (int)jsonObject.getJSONObject("1206").get("brokeBuy");
                        j[56]= (int)jsonObject.getJSONObject("1306").get("brokeBuy");
                    }
                    roomsUserInfo.setBrokeBuy(j);
                    j = new Integer[57];
                    j[0] = list.get(i).getActive();
                    j[1] = list.get(i).getActive1();
                    j[2] = list.get(i).getActive2();
                    j[3] = list.get(i).getActive3();
                    j[4] = list.get(i).getActive4();
                    j[5] = list.get(i).getActive5();
                    j[6] = list.get(i).getActive6();
                    j[7] = list.get(i).getActive7();
                    j[8] = list.get(i).getActive8();
                    j[9] = list.get(i).getActive9();
                    j[10] = list.get(i).getActive10();
                    j[11] = list.get(i).getActive11();
                    j[12] = list.get(i).getActive12();
                    j[13] = list.get(i).getActive13();
                    j[14] = list.get(i).getActive14();
                    j[15] = list.get(i).getActive15();
                    j[16] = list.get(i).getActive16();
                    j[17] = list.get(i).getActive17();
                    j[18] = list.get(i).getActive18();
                    j[19] = list.get(i).getActive19();
                    j[20] = list.get(i).getActive20();
                    j[21] = list.get(i).getActive21();
                    j[22] = list.get(i).getActive22();
                    j[23] = list.get(i).getActive23();
                    j[24] = list.get(i).getActive24();
                    j[25] = list.get(i).getActive25();
                    j[26] = list.get(i).getActive26();
                    j[27] = list.get(i).getActive27();
                    j[28] = list.get(i).getActive28();
                    j[29] = list.get(i).getActive29();
                    j[30] = list.get(i).getActive30();
                    j[31] = list.get(i).getActive31();
                    if(list.get(i).getBroke32()!=null) {
                        j[32] = list.get(i).getActive32();
                        j[33] = list.get(i).getActive33();
                        j[34] = list.get(i).getActive34();
                        j[35] = list.get(i).getActive35();
                        j[36] = list.get(i).getActive36();
                        j[37] = list.get(i).getActive37();
                        j[38] = list.get(i).getActive38();
                        j[39] = list.get(i).getActive39();
                        j[40] = list.get(i).getActive40();
                        j[41] = list.get(i).getActive41();
                        j[42] = list.get(i).getActive42();
                        j[43] = list.get(i).getActive43();
                    }
                    if(jsonObject!=null){
                        j[44]= (int)jsonObject.getJSONObject("106").get("money");
                        j[45]= (int)jsonObject.getJSONObject("206").get("money");
                        j[46]= (int)jsonObject.getJSONObject("306").get("money");
                        j[47]= (int)jsonObject.getJSONObject("406").get("money");
                        j[48]= (int)jsonObject.getJSONObject("506").get("money");
                        j[49]= (int)jsonObject.getJSONObject("606").get("money");
                        j[50]= (int)jsonObject.getJSONObject("706").get("money");
                        j[51]= (int)jsonObject.getJSONObject("806").get("money");
                        j[52]= (int)jsonObject.getJSONObject("906").get("money");
                        j[53]= (int)jsonObject.getJSONObject("1006").get("money");
                        j[54]= (int)jsonObject.getJSONObject("1106").get("money");
                        j[55]= (int)jsonObject.getJSONObject("1206").get("money");
                        j[56]= (int)jsonObject.getJSONObject("1306").get("money");
                    }
                    roomsUserInfo.setBrokeMoney(j);
                }
                }
                if(roomsUserInfo.getChannel().equals("h5hzmjxl_wechat")||roomsUserInfo.getChannel().equals("h5hzmjxl_qq")||roomsUserInfo.getChannel().equals("h5hcmjxl_wechat")||roomsUserInfo.getChannel().equals("h5gdmjxl_wechat")) {
                    if(roomsUserInfo.getTheFather().equals("h5hzmjxl_wechat")||roomsUserInfo.getTheFather().equals("h5hzmjxl_qq")||roomsUserInfo.getTheFather().equals("h5hcmjxl_wechat")||roomsUserInfo.getTheFather().equals("h5gdmjxl_wechat")){
                        roomsUserInfo.setHasChildren(false);
                    }
                }else if(roomsUserInfo.getChannel().indexOf("_total")>0){

                }
                else {
                    roomsUserInfo.setHasChildren(false);
                }
            }
        }
        return list1;
    }

    @Override
    public Map signPlayers(UserEntity userEntity, Pageable pageable) throws IOException {
        JSONObject jsonObject = new JSONObject();
//        jsonObject.put("pid",abnormalOrdersEntity.getPid());
//        jsonObject.put("time",abnormalOrdersEntity.getTime()/1000);
        JSONObject map = new JSONObject();
        map.put("cmd","getOnlineMarkP");
        map.put("args",jsonObject);
        String result = null;
        result = HttpUtil.post(RequestConfig.baseRequestUrl, map.toJSONString(),"utf-8");
        JSONArray jSONArray= new JSONArray();
        if(!result .equals("{}")  && result !=null){
            jSONArray=JSONObject.parseArray(result);
        }
        Query query = new Query();
        query.skip((pageable.getPageNumber())*pageable.getPageSize());
        query.limit(pageable.getPageSize());
        Criteria criteria = new Criteria();
        criteria.and("userid").in(jSONArray);
        query.addCriteria(criteria);
        query.with( Sort.by(Sort.Direction.DESC,new String[]{"reg_time"}));
        List<UserEntity> list = mongoTemplate.find(query, UserEntity.class);
        long total = mongoTemplate.count(query, UserEntity.class);
        Map map2 =new HashMap();
        map2.put("content",list);
        map2.put("totalElements",total);
        return map2;
    }

    @Autowired
    private PlayerNumberMapper playerNumberMapper;

    @Autowired
    private LostGoldMapper lostGoldMapper;

    @Autowired
    private GoldRecCountMapper goldRecCountMapper;

    @Override
    public Map getPlayerNumber(PlayerNumber playerNumber,Pageable pageable)throws IOException{
        Page<PlayerNumber> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        Page<LostGold> page1 = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<PlayerNumber> wrapper =new QueryWrapper<>();
        QueryWrapper<LostGold> wrapper1=new QueryWrapper<>();
        QueryWrapper<LostGold> wrapper2=new QueryWrapper<>();
        if(playerNumber.getQTime()!=null){
            wrapper.ge("time",playerNumber.getQTime().get(0).getTime()/1000);
            wrapper.le("time",playerNumber.getQTime().get(1).getTime()/1000);
            wrapper1.ge("time",playerNumber.getQTime().get(0).getTime()/1000);
            wrapper1.le("time",playerNumber.getQTime().get(1).getTime()/1000);
            wrapper2.ge("time",playerNumber.getQTime().get(0).getTime()/1000);
            wrapper2.le("time",playerNumber.getQTime().get(1).getTime()/1000);
        }
        if(playerNumber.getChannel()==null){
            wrapper.eq("channel","total");
            wrapper1.eq("channel","total");
            wrapper2.eq("channel","total");
        }else{
            wrapper.eq("channel",playerNumber.getChannel());
            wrapper1.eq("channel",playerNumber.getChannel());
            wrapper2.eq("channel",playerNumber.getChannel());
        }
        wrapper.orderByDesc("time");
        wrapper1.orderByDesc("time");
        wrapper2.orderByDesc("time");
        IPage<PlayerNumber> ipage = playerNumberMapper.selectPage(page,wrapper);
        List<PlayerNumber> list = ipage.getRecords();
        String[] xData=new String[list.size()];
        Map yDataMaps = new HashMap();
        if(list.size()>0) {
            for (int i = 0; i < list.size(); i++) {
                xData[i] = DateUtil.timeStamp2Date(list.get(i).getTime() + "", "yyyy-MM-dd ").trim();
                int act=list.get(i).getActNum()-(list.get(i).getPlayerNum1()+list.get(i).getPlayerNum2()+list.get(i).getPlayerNum3()+list.get(i).getPlayerNum4()+list.get(i).getPlayerNum5()+
                        list.get(i).getPlayerNum6()+list.get(i).getPlayerNum7()+list.get(i).getPlayerNum8()+list.get(i).getPlayerNum9()+list.get(i).getPlayerNum10()+list.get(i).getPlayerNum11()+
                        list.get(i).getPlayerNum12()+list.get(i).getPlayerNum13()+list.get(i).getPlayerNum14()+list.get(i).getPlayerNum15()+list.get(i).getPlayerNum16()+list.get(i).getPlayerNum17());
               int qwe[]={act,list.get(i).getPlayerNum1(),list.get(i).getPlayerNum2(),list.get(i).getPlayerNum3(),list.get(i).getPlayerNum4(),list.get(i).getPlayerNum5(),
                        list.get(i).getPlayerNum6(),list.get(i).getPlayerNum7(),list.get(i).getPlayerNum8(),list.get(i).getPlayerNum9(),list.get(i).getPlayerNum10(),list.get(i).getPlayerNum11(),
                        list.get(i).getPlayerNum12(),list.get(i).getPlayerNum13(),list.get(i).getPlayerNum14(),list.get(i).getPlayerNum15(),list.get(i).getPlayerNum16(),list.get(i).getPlayerNum17()};
                yDataMaps.put( (i+1)+"",qwe);
            }
        }
        wrapper1.eq("flag","lostGold");
        IPage<LostGold> ipage1 = lostGoldMapper.selectPage(page1,wrapper1);
        List<LostGold> list1 = ipage1.getRecords();
        String[] xxData=new String[list1.size()];
        Map yyDataMaps = new HashMap();
        if(list1.size()>0) {
            for (int i = 0; i < list1.size(); i++) {
                xxData[i] = DateUtil.timeStamp2Date(list1.get(i).getTime() + "", "yyyy-MM-dd ").trim();
                yyDataMaps.put( (i+1)+"",list1.get(i).getLostGold().split("@"));
            }
        }


        wrapper2.eq("flag","bankruptcy");
        IPage<LostGold> bankruptcyIpage=lostGoldMapper.selectPage(page1,wrapper2);
        List<LostGold>  bankruptcyList=bankruptcyIpage.getRecords();
        String[] rupatcyData=new String[bankruptcyList.size()];
        Map bankruptcy=new HashMap();
        if(bankruptcyList.size()>0){
            for (int i = 0; i < bankruptcyList.size(); i++) {
                rupatcyData[i] = DateUtil.timeStamp2Date(bankruptcyList.get(i).getTime() + "", "yyyy-MM-dd ").trim();
                bankruptcy.put( (i+1)+"",bankruptcyList.get(i).getLostGold().split("@"));
            }
        }

        QueryWrapper<GoldRecCount> wrapper3=new QueryWrapper<>();
        wrapper3.eq("channel",playerNumber.getChannel());
        wrapper3.orderByDesc("time");
        Page<GoldRecCount> page2 = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        Map DataMaps = new HashMap();
        IPage<GoldRecCount> ipage2=goldRecCountMapper.selectPage(page2,wrapper3);
        List<GoldRecCount> list2= ipage2.getRecords();
        String[] yData=new String[list2.size()];;
        if(list2.size()>0) {
            for (int i = 0; i < list2.size(); i++) {
                DataMaps.put( (i+1)+"",list2.get(i).getGoldCount().split(","));
                yData[i]=DateUtil.timeStamp2Date(list2.get(i).getTime() + "", "yyyy-MM-dd ").trim();
            }
        }

        Map map=new HashMap();
        map.put("chartData",yDataMaps);
        map.put("xData",xData);
        map.put("content",list);
        map.put("totalElements",list.size());
        map.put("countData",1);
        map.put("xchartData",yyDataMaps);
        map.put("xxData",xxData);
        map.put("xxchartData",DataMaps);
        map.put("xxxData",yData);
        map.put("bankruptcy",bankruptcy);
        map.put("rupatcyData",rupatcyData);
        return map;
    }
  @Autowired
  private BrokeInfoMapper brokeInfoMapper;

    @Override
   public Map getBrokeList(BrokeInfo brokeInfo, Pageable pageable){
       Page<BrokeInfo> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
       QueryWrapper<BrokeInfo> wrapper =new QueryWrapper<>();
       if(brokeInfo.getQTime()!=null){
           wrapper.ge("time",brokeInfo.getQTime().get(0).getTime()/1000);
           wrapper.le("time",brokeInfo.getQTime().get(1).getTime()/1000);
       }
       if(brokeInfo.getChannel()!=null){
           wrapper.eq("channel",brokeInfo.getChannel());
       }else{
           wrapper.eq("channel","total").or().isNull("channel");

       }
       if(brokeInfo.getTime()!=null&&brokeInfo.getTime()>0){
           wrapper.eq("time",brokeInfo.getTime());
           wrapper.ne("channel","total");
       }
       wrapper.orderBy(true,false,"time");
       IPage<BrokeInfo> ipage = brokeInfoMapper.selectPage(page,wrapper);
       List<BrokeInfo> list = ipage.getRecords();
       Map map =new HashMap();
       map.put("content",list);
       map.put("totalElements",ipage.getTotal());
       return map;
   }

    @Override
    public List<BrokeInfo> getBrokeList( Integer time,String channel){
        QueryWrapper<BrokeInfo> wrapper =new QueryWrapper<>();
        if(time!=null&&time>0){
            wrapper.eq("time",time);
            wrapper.eq("the_father",channel);
        }
        wrapper.orderBy(true,false,"id");
        List<BrokeInfo> list = brokeInfoMapper.selectList(wrapper);
        if(list.size()>0){
            for(BrokeInfo brokeInfo:list){
                if(brokeInfo.getChannel().equals("h5hzmjxl_wechat")||brokeInfo.getChannel().equals("h5hzmjxl_qq")||brokeInfo.getChannel().equals("h5hcmjxl_wechat")||brokeInfo.getChannel().equals("h5gdmjxl_wechat")) {
                    if(brokeInfo.getTheFather().equals("h5hzmjxl_wechat")||brokeInfo.getTheFather().equals("h5hzmjxl_qq")||brokeInfo.getTheFather().equals("h5hcmjxl_wechat")||brokeInfo.getTheFather().equals("h5gdmjxl_wechat")){
                        brokeInfo.setHasChildren(false);
                    }
                }else {
                    brokeInfo.setHasChildren(false);
                }
            }
        }
        return list;
    }

    @Autowired
    private AvgUserDayInfoMapper avgUserDayInfoMapper;

    @Override
   public Map getAvgUserInfo(AvgUserDayInfo avgUserDayInfo, Pageable pageable){
        Page<AvgUserDayInfo> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<AvgUserDayInfo> wrapper =new QueryWrapper<>();
        if(avgUserDayInfo.getChannel()!=null){
            wrapper.eq("channel",avgUserDayInfo.getChannel());
        }else {
            wrapper.eq("channel","total");
        }
        if (avgUserDayInfo.getQTime()!=null){
            wrapper.gt("time",avgUserDayInfo.getQTime().get(0).getTime()/1000-1).lt("time",avgUserDayInfo.getQTime().get(1).getTime()/1000+1);
        }
        if(avgUserDayInfo.getFlag()!=null){
            wrapper.eq("flag",avgUserDayInfo.getFlag());
        }else {
            wrapper.eq("flag","all");
        }
        wrapper.orderByDesc("time");
        //绑定玩家总数量
        IPage<AvgUserDayInfo> ipage = avgUserDayInfoMapper.selectPage(page,wrapper);
        List<AvgUserDayInfo> list = ipage.getRecords();
        Map map=new HashMap();
        map.put("content",list);
        map.put("totalElements",ipage.getTotal());
        return map;
   }

    @Autowired
    private UserPayRateInfoMapper userPayRateInfoMapper;

    @Autowired
    private ChannelLtvMapper channelLtvMapper;

    @Override
    public Map getChargeUserRateLtvInfo(UserPayRateInfo userPayRateInfo, Pageable pageable){
        Page<UserPayRateInfo> page = new Page<>(pageable.getPageNumber()+1,pageable.getPageSize());
        QueryWrapper<UserPayRateInfo> wrapper =new QueryWrapper<>();
        if(userPayRateInfo.getChannel()!=null){
            wrapper.eq("channel",userPayRateInfo.getChannel());
        }else {
            wrapper.eq("channel","total");
        }
        if (userPayRateInfo.getQTime()!=null){
            wrapper.gt("time",userPayRateInfo.getQTime().get(0).getTime()/1000-1).lt("time",userPayRateInfo.getQTime().get(1).getTime()/1000+1);
        }
        wrapper.orderByDesc("time");
        //绑定玩家总数量
        IPage<UserPayRateInfo> ipage = userPayRateInfoMapper.selectPage(page,wrapper);
        List<UserPayRateInfo> list = ipage.getRecords();
        if(list.size()>0){
            for (UserPayRateInfo userPayRateInfo1:list){
               QueryWrapper<ChannelLtv> wrapper1=new QueryWrapper<>();
               wrapper1.eq("channel","topon_douyin");
               wrapper1.eq("time",userPayRateInfo1.getTime());
               ChannelLtv channelLtv = channelLtvMapper.selectOne(wrapper1);
               String[] re=new String[11];
               if(channelLtv!=null) {
                   re[0] = channelLtv.getRegNum() + "";
                   re[1] = channelLtv.getTotalCharge1() + "";
                   re[2] = channelLtv.getTotalCharge2() + "";
                   re[3] = channelLtv.getTotalCharge3() + "";
                   re[4] = channelLtv.getTotalCharge4() + "";
                   re[5] = channelLtv.getTotalCharge5() + "";
                   re[6] = channelLtv.getTotalCharge6() + "";
                   re[7] = channelLtv.getTotalCharge7() + "";
                   re[8] = channelLtv.getTotalCharge14() + "";
                   re[9] = channelLtv.getTotalCharge30() + "";
                   re[10] = channelLtv.getTotalCharge60() + "";
               }
                userPayRateInfo1.setLtv(re);
            }
        }
        Map map=new HashMap();
        map.put("content",list);
        map.put("totalElements",ipage.getTotal());
        return map;
    }
}
